Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace SecurityService.OpenIdConnect.IntegrationTests.ChangePassword
using OpenQA.Selenium;
using Reqnroll;
using SecurityService.IntegrationTests.UserLogin;
using Shared.IntegrationTesting;
using Shouldly;

[Binding]
Expand Down Expand Up @@ -75,9 +76,12 @@ public async Task WhenIClickTheChangePasswordButton()
}

[Then(@"I am returned to the application home page")]
public void ThenIAmReturnedToTheApplicationHomePage()
public async Task ThenIAmReturnedToTheApplicationHomePage()
{
this.WebDriver.Title.ShouldBe("Home Page - SecurityServiceTestUI");
await Retry.For(async () =>
{
this.WebDriver.Title.ShouldBe("Home Page - SecurityServiceTestUI");
});
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,17 @@ public async Task BeforeScenario()
{
ChromeOptions options = new ChromeOptions();
options.AddArguments("--disable-gpu");
options.AddArguments("--headless");
options.AddArguments("--headless=new");
options.AddArguments("--no-sandbox");
options.AddArguments("--disable-dev-shm-usage");
options.AddArguments("disable-infobars");
options.AddArguments("--disable-extensions");
options.AddArguments("--window-size=1280x1024");
options.AcceptInsecureCertificates = true;
this.WebDriver = new ChromeDriver(options);
await Retry.For(async () =>
{
this.WebDriver = new ChromeDriver(options);
}, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(60));
this.WebDriver.Manage().Window.Maximize();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public async Task ThenIAmPresentedWithTheResetPasswordScreen()
[Then("I am presented with the reset password request sent screen")]
public async Task ThenIAmPresentedWithTheResetPasswordRequestSentScreen()
{
IWebElement resetPasswordLabel = this.WebDriver.FindElement(By.Id("forgotPasswordMessage"));
await Retry.For(async () => {
IWebElement resetPasswordLabel = this.WebDriver.FindElement(By.Id("forgotPasswordMessage"));
resetPasswordLabel.ShouldNotBeNull();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,31 +53,37 @@ public UserLoginSteps(TestingContext testingContext,
#endregion

[Given(@"I am on the application home page")]
public void GivenIAmOnTheApplicationHomePage()
public async Task GivenIAmOnTheApplicationHomePage()
{
this.WebDriver.Navigate().GoToUrl($"https://localhost:{this.TestingContext.DockerHelper.SecurityServiceTestUIPort}");
this.WebDriver.Title.ShouldBe("Home Page - SecurityServiceTestUI");
await Retry.For(async () =>
{
this.WebDriver.Title.ShouldBe("Home Page - SecurityServiceTestUI");
});
}

[When(@"I click the '(.*)' link")]
public void WhenIClickTheLink(string linkText)
public async Task WhenIClickTheLink(string linkText)
{
this.WebDriver.ClickLink(linkText);
await this.WebDriver.ClickLink(linkText);
}

[Then(@"I am presented with a login screen")]
public async Task ThenIAmPresentedWithALoginScreen()
{
IWebElement loginButton = await this.WebDriver.FindButton("Login");
loginButton.ShouldNotBeNull();
await Retry.For(async () =>
{
IWebElement loginButton = await this.WebDriver.FindButton("Login");
loginButton.ShouldNotBeNull();
});
}

[When(@"I login with the username '([^']*)' and the provided password")]
public void WhenILoginWithTheUsernameAndTheProvidedPassword(string userName)
public async Task WhenILoginWithTheUsernameAndTheProvidedPassword(string userName)
{
this.WebDriver.FillIn("Input.Username", userName);
this.WebDriver.FillIn("Input.Password", this.TestingContext.Password);
this.WebDriver.ClickButton("Login");
await this.WebDriver.ClickButton("Login");
}


Expand All @@ -87,10 +93,6 @@ public async Task ThenIAmPresentedWithThePrivacyScreen()
{
await Retry.For(async () =>
{
var page = this.WebDriver.PageSource;

Console.WriteLine($"Source Is [{page}");

this.WebDriver.Title.ShouldBe("Privacy Policy - SecurityServiceTestUI");
});

Expand Down Expand Up @@ -165,9 +167,12 @@ public void WhenINavigateToTheConfirmEmailAddress() {
}

[Then(@"I am presented with the confirm email address successful screen")]
public void ThenIAmPresentedWithTheConfirmEmailAddressSuccessfulScreen() {
IWebElement webElement = this.WebDriver.FindElement(By.Id("userMessage"));
webElement.Text.ShouldBe("Thanks for confirming your email address, you should receive a welcome email soon.");
public async Task ThenIAmPresentedWithTheConfirmEmailAddressSuccessfulScreen() {
await Retry.For(async () =>
{
IWebElement webElement = this.WebDriver.FindElement(By.Id("userMessage"));
webElement.Text.ShouldBe("Thanks for confirming your email address, you should receive a welcome email soon.");
});
}

}
Expand All @@ -184,16 +189,14 @@ public static void FillIn(this IWebDriver webDriver,
}

public static async Task<IWebElement> FindButton(this IWebDriver webDriver,
String buttonText)
String buttonText)
{
IWebElement e = null;
await Retry.For(async () =>
{


ReadOnlyCollection<IWebElement> elements = webDriver.FindElements(By.TagName("button"));

var foundElements = elements.Where(e => e.GetAttribute("innerText") == buttonText).ToList();
var foundElements = elements.Where(element => element.Text.Trim() == buttonText).ToList();
foundElements.ShouldHaveSingleItem();

e = foundElements.Single();
Expand All @@ -202,12 +205,15 @@ await Retry.For(async () =>
return e;
}

public static void ClickLink(this IWebDriver webDriver,
String linkText)
public static async Task ClickLink(this IWebDriver webDriver,
String linkText)
{
IWebElement webElement = webDriver.FindElement(By.LinkText(linkText));
webElement.ShouldNotBeNull();
webElement.Click();
await Retry.For(async () =>
{
IWebElement webElement = webDriver.FindElement(By.LinkText(linkText));
webElement.ShouldNotBeNull();
webElement.Click();
});
}

public static async Task ClickButton(this IWebDriver webDriver,
Expand Down
Loading