diff --git a/.github/workflows/nightlybuild.yml b/.github/workflows/nightlybuild.yml index a9bb789..0269e92 100644 --- a/.github/workflows/nightlybuild.yml +++ b/.github/workflows/nightlybuild.yml @@ -292,8 +292,6 @@ jobs: - name: Run Integration Tests (UI Edge) env: Browser: Edge - DriverPath: C:\\SeleniumWebDrivers\\EdgeDriver\\ - DriverExe: msedgedriver.exe run: | dotnet test "SecurityService.OpenIdConnect.IntegrationTests\SecurityService.OpenIdConnect.IntegrationTests.csproj" --filter Category=PRTest diff --git a/SecurityService.OpenIdConnect.IntegrationTests/Common/BrowserNavigation.cs b/SecurityService.OpenIdConnect.IntegrationTests/Common/BrowserNavigation.cs new file mode 100644 index 0000000..f3aa95b --- /dev/null +++ b/SecurityService.OpenIdConnect.IntegrationTests/Common/BrowserNavigation.cs @@ -0,0 +1,23 @@ +using System; +using System.Threading.Tasks; +using OpenQA.Selenium; + +namespace SecurityService.IntergrationTests.Common; + +public static class BrowserNavigation +{ + public static async Task NavigateWithDiagnosticsAsync( + Func navigate, + Action log = null) + { + try + { + await navigate(); + } + catch (WebDriverException exception) + { + log?.Invoke($"Browser navigation failed without retry because the URL may be state-changing: {exception.Message}"); + throw; + } + } +} diff --git a/SecurityService.OpenIdConnect.IntegrationTests/Common/BrowserNavigationTests.cs b/SecurityService.OpenIdConnect.IntegrationTests/Common/BrowserNavigationTests.cs new file mode 100644 index 0000000..a6e2d23 --- /dev/null +++ b/SecurityService.OpenIdConnect.IntegrationTests/Common/BrowserNavigationTests.cs @@ -0,0 +1,28 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; +using OpenQA.Selenium; + +namespace SecurityService.IntergrationTests.Common; + +[TestFixture] +public class BrowserNavigationTests +{ + [Test] + public async Task NavigateWithDiagnosticsAsync_DoesNotRetryAfterNavigationFailure() + { + Int32 attempts = 0; + String logMessage = String.Empty; + + Assert.ThrowsAsync(async () => await BrowserNavigation.NavigateWithDiagnosticsAsync( + async () => + { + attempts++; + throw new WebDriverException("navigation failure"); + }, + message => logMessage = message)); + + Assert.That(attempts, Is.EqualTo(1)); + Assert.That(logMessage, Does.Contain("navigation failure")); + } +} diff --git a/SecurityService.OpenIdConnect.IntegrationTests/Common/Hooks.cs b/SecurityService.OpenIdConnect.IntegrationTests/Common/Hooks.cs index 488dd19..e088ce4 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/Common/Hooks.cs +++ b/SecurityService.OpenIdConnect.IntegrationTests/Common/Hooks.cs @@ -104,15 +104,18 @@ await Retry.For(async () => { EdgeOptions options = new EdgeOptions(); options.AcceptInsecureCertificates = true; + options.PageLoadStrategy = PageLoadStrategy.Eager; options.AddArguments("--headless=new"); options.AddArguments("--window-size=1280x1024"); options.AddArguments("--no-sandbox"); options.AddArguments("--disable-dev-shm-usage"); options.AddArguments("--disable-gpu"); + options.AddArguments("--host-resolver-rules=MAP identity-server 127.0.0.1"); await Retry.For(async () => { this.WebDriver = new EdgeDriver(options); }, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(60)); + this.WebDriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(45); } this.ObjectContainer.RegisterInstanceAs(this.WebDriver); diff --git a/SecurityService.OpenIdConnect.IntegrationTests/UserLogin/UserLoginSteps.cs b/SecurityService.OpenIdConnect.IntegrationTests/UserLogin/UserLoginSteps.cs index bb78ea3..861b274 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/UserLogin/UserLoginSteps.cs +++ b/SecurityService.OpenIdConnect.IntegrationTests/UserLogin/UserLoginSteps.cs @@ -162,8 +162,15 @@ public async Task ThenIGetAWelcomeEmailWithMyLoginDetails() [When(@"I navigate to the confirm email address")] - public void WhenINavigateToTheConfirmEmailAddress() { - this.WebDriver.Navigate().GoToUrl(this.TestingContext.ConfirmEmailAddressLink); + public async Task WhenINavigateToTheConfirmEmailAddress() + { + await BrowserNavigation.NavigateWithDiagnosticsAsync( + () => + { + this.WebDriver.Navigate().GoToUrl(this.TestingContext.ConfirmEmailAddressLink); + return Task.CompletedTask; + }, + message => this.TestingContext.DockerHelper.Logger.LogInformation(message)); } [Then(@"I am presented with the confirm email address successful screen")]