Skip to content

Commit

Permalink
Wait for pages to load in SAMLServiceProviderTest
Browse files Browse the repository at this point in the history
Closes keycloak#609

Signed-off-by: rmartinc <[email protected]>
  • Loading branch information
rmartinc committed Nov 18, 2024
1 parent 24b26f4 commit 61dc21c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ jobs:
tests:
name: Jakarta
runs-on: ubuntu-latest
strategy:
matrix:
group: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.Graphene;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
Expand All @@ -37,6 +36,15 @@ public boolean isOnStartPage() {
return browser.findElements(By.name("loginBtn")).size() > 0;
}

public void waitForStartPage() {
fixStylesPage();
try {
Graphene.waitAjax().until().element(By.name("loginBtn")).is().present();
} catch (TimeoutException ex) {
throw new TimeoutException("timeout on page " + browser.getCurrentUrl(), ex);
}
}

public void waitForAccountBtn() {
fixStylesPage();
try {
Expand All @@ -61,4 +69,12 @@ public void isOnLoginPage() {
throw new TimeoutException("timeout on page " + browser.getCurrentUrl(), ex);
}
}

public void waitUntilTitle(String title) {
try {
Graphene.waitAjax().until((WebDriver driver) -> driver.getTitle().contains(title));
} catch (TimeoutException ex) {
throw new TimeoutException("timeout on page " + browser.getCurrentUrl(), ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public void setup() {
public void testLogin() {
try {
indexPage.clickLogin();
pageHelper.waitUntilTitle("Sign in to quickstart");
loginPage.login("alice", "alice");
// due to https://issues.redhat.com/browse/KEYCLOAK-14103 a second click to login is required
// need to upgrade to Wildfly 19.1.0 to support a solution to this
Expand All @@ -118,6 +119,7 @@ public void testLogin() {
pageHelper.waitForAccountBtn();
assertEquals(profilePage.getUsername(), "alice");
profilePage.clickLogout();
pageHelper.waitForStartPage();
assertTrue(pageHelper.isOnStartPage());
indexPage.clickLogin();
pageHelper.isOnLoginPage();
Expand All @@ -131,6 +133,7 @@ public void testLogin() {
public void testAccessAccountManagement() {
try {
indexPage.clickLogin();
pageHelper.waitUntilTitle("Sign in to quickstart");
loginPage.login("alice", "alice");
// due to https://issues.redhat.com/browse/KEYCLOAK-14103 a second click to login is required
// need to upgrade to Wildfly 19.1.0 to support a solution to this
Expand All @@ -140,6 +143,7 @@ public void testAccessAccountManagement() {
}
pageHelper.waitForAccountBtn();
profilePage.clickAccount();
pageHelper.waitUntilTitle("Account Management");
assertTrue(webDriver.getTitle().contains("Account Management"));
} catch (Exception e) {
debugTest(e);
Expand Down

0 comments on commit 61dc21c

Please sign in to comment.