Skip to content

Commit

Permalink
Merge pull request #276 from Lombiq/issue/SPAL-21
Browse files Browse the repository at this point in the history
SPAL-21: Added point to Troubleshooting
  • Loading branch information
0liver authored May 25, 2023
2 parents c38f36c + b609833 commit decb167
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lombiq.Tests.UI/Docs/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
3. Run `dotnet dev-certs https --trust` and accept the security warning that pops up. (This is why we can't automate all of this.)
4. Now `dotnet dev-certs https --check --verbose` should display "A valid certificate was found."
- If you have retries configured for the tests and they've been running for a long time without any visible progress then most possibly all of them are failing. This can happen e.g. if the setup or initialization steps are failing. However, by default the `OrchardCoreUITestExecutorConfiguration.FastFailSetup` configuration will quickly fail all affected tests if a common setup operation is failing, without retrying it for all tests.
- If tests fail at the start with the exception screen saying ``InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.ILookupNormalizer' while attempting to activate 'Microsoft.AspNetCore.Identity.RoleManager`1[OrchardCore.Security.IRole]'.``, add the `Lombiq.Tests.UI.Shortcuts` dependency to your web project.

## Issues with driving browsers

Expand Down
16 changes: 16 additions & 0 deletions Lombiq.Tests.UI/Extensions/NavigationUITestContextExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,22 @@ public static void DismissAlert(this UITestContext context)
context.Driver.SwitchTo().DefaultContent();
}

/// <summary>
/// Clicks on the first matching element, switches control to the JS alert/prompt box that's expected to appear,
/// enters <paramref name="inputText"/> as keystrokes if it's not <see langword="null"/>, accepts the alert/prompt
/// box, and switches control back to main document or first frame.
/// </summary>
public static void ClickAndAcceptPrompt(this UITestContext context, By by, string inputText = null)
{
// Using FindElement() here because ClickReliablyOnAsync() would throw an "Unexpected Alert Open" exception.
context.Driver.FindElement(by).Click();

var alert = context.Driver.SwitchTo().Alert();
if (inputText != null) alert.SendKeys(inputText);
alert.Accept();
context.Driver.SwitchTo().DefaultContent();
}

/// <summary>
/// Refreshes (reloads) the current page.
/// </summary>
Expand Down

0 comments on commit decb167

Please sign in to comment.