Fix for WebAuthn tests
This commit is contained in:
parent
08fccf5a9f
commit
4f66087bf4
3 changed files with 25 additions and 7 deletions
|
@ -20,10 +20,10 @@ package org.keycloak.testsuite.page;
|
|||
import org.jboss.arquillian.drone.api.annotation.Drone;
|
||||
import org.jboss.logging.Logger;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.TimeoutException;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.FindBy;
|
||||
import org.openqa.selenium.support.ui.ExpectedCondition;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||
|
||||
|
@ -56,9 +56,17 @@ public abstract class AbstractPatternFlyAlert {
|
|||
}
|
||||
|
||||
public static void waitUntilDisplayed() {
|
||||
new WebDriverWait(getCurrentDriver(), PAGELOAD_TIMEOUT_MILLIS / 1000).until(
|
||||
ExpectedConditions.visibilityOfElementLocated(By.className(ALERT_CLASS_NAME))
|
||||
);
|
||||
waitUntilDisplayedOrHidden(true);
|
||||
}
|
||||
|
||||
public static void waitUntilHidden() {
|
||||
waitUntilDisplayedOrHidden(false);
|
||||
}
|
||||
|
||||
private static void waitUntilDisplayedOrHidden(boolean displayed) {
|
||||
ExpectedCondition condition = ExpectedConditions.visibilityOfElementLocated(By.className(ALERT_CLASS_NAME));
|
||||
condition = displayed ? condition : ExpectedConditions.not(condition);
|
||||
new WebDriverWait(getCurrentDriver(), PAGELOAD_TIMEOUT_MILLIS / 1000).until(condition);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jboss.arquillian.graphene.page.Page;
|
|||
import org.keycloak.testsuite.console.page.authentication.Authentication;
|
||||
import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
|
||||
import org.keycloak.testsuite.console.page.idp.mappers.MultivaluedStringProperty;
|
||||
import org.keycloak.testsuite.page.AbstractPatternFlyAlert;
|
||||
import org.keycloak.testsuite.webauthn.utils.PropertyRequirement;
|
||||
import org.openqa.selenium.NoSuchElementException;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
@ -36,6 +37,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import static org.keycloak.testsuite.util.UIUtils.getTextInputValue;
|
||||
import static org.keycloak.testsuite.util.UIUtils.setTextInputValue;
|
||||
import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad;
|
||||
import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
|
||||
|
||||
/**
|
||||
|
@ -98,7 +100,7 @@ public class WebAuthnPolicyPage extends Authentication {
|
|||
}
|
||||
|
||||
public void setRpEntityName(String entityName) {
|
||||
waitUntilElement(checkElement(() -> rpEntityName)).is().present();
|
||||
waitUntilElement(checkElement(() -> rpEntityName)).is().clickable();
|
||||
setTextInputValue(rpEntityName, entityName);
|
||||
}
|
||||
|
||||
|
@ -118,7 +120,7 @@ public class WebAuthnPolicyPage extends Authentication {
|
|||
}
|
||||
|
||||
public void setRpEntityId(String id) {
|
||||
waitUntilElement(checkElement(() -> rpEntityId)).is().present();
|
||||
waitUntilElement(checkElement(() -> rpEntityId)).is().clickable();
|
||||
setTextInputValue(rpEntityId, id);
|
||||
}
|
||||
|
||||
|
@ -201,7 +203,7 @@ public class WebAuthnPolicyPage extends Authentication {
|
|||
}
|
||||
|
||||
public void setTimeout(Integer time) {
|
||||
waitUntilElement(checkElement(() -> timeout)).is().present();
|
||||
waitUntilElement(checkElement(() -> timeout)).is().clickable();
|
||||
setTextInputValue(timeout, time == null ? "0" : String.valueOf(time));
|
||||
}
|
||||
|
||||
|
@ -224,11 +226,13 @@ public class WebAuthnPolicyPage extends Authentication {
|
|||
public void clickSaveButton() {
|
||||
waitUntilElement(checkElement(() -> saveButton)).is().clickable();
|
||||
saveButton.click();
|
||||
waitForPageToLoad();
|
||||
}
|
||||
|
||||
public void clickCancelButton() {
|
||||
waitUntilElement(checkElement(() -> cancelButton)).is().clickable();
|
||||
cancelButton.click();
|
||||
waitForPageToLoad();
|
||||
}
|
||||
|
||||
public boolean isSaveButtonEnabled() {
|
||||
|
|
|
@ -27,7 +27,9 @@ import org.keycloak.models.Constants;
|
|||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.testsuite.AssertEvents;
|
||||
import org.keycloak.testsuite.console.AbstractConsoleTest;
|
||||
import org.keycloak.testsuite.page.AbstractPatternFlyAlert;
|
||||
import org.keycloak.testsuite.util.UIUtils;
|
||||
import org.keycloak.testsuite.util.WaitUtils;
|
||||
import org.keycloak.testsuite.webauthn.pages.WebAuthnPolicyPage;
|
||||
import org.keycloak.testsuite.webauthn.updaters.AbstractWebAuthnRealmUpdater;
|
||||
import org.keycloak.testsuite.webauthn.utils.PropertyRequirement;
|
||||
|
@ -65,6 +67,7 @@ public abstract class AbstractWebAuthnPolicySettingsTest extends AbstractConsole
|
|||
|
||||
@Before
|
||||
public void navigateToPolicy() {
|
||||
driver.manage().window().maximize();
|
||||
getPolicyPage().navigateTo();
|
||||
waitForPageToLoad();
|
||||
getPolicyPage().assertCurrent();
|
||||
|
@ -110,6 +113,7 @@ public abstract class AbstractWebAuthnPolicySettingsTest extends AbstractConsole
|
|||
|
||||
getPolicyPage().setRpEntityName("newEntityName");
|
||||
getPolicyPage().clickSaveButton();
|
||||
AbstractPatternFlyAlert.waitUntilHidden();
|
||||
|
||||
rpEntityName = getPolicyPage().getRpEntityName();
|
||||
assertThat(rpEntityName, notNullValue());
|
||||
|
@ -117,6 +121,7 @@ public abstract class AbstractWebAuthnPolicySettingsTest extends AbstractConsole
|
|||
|
||||
getPolicyPage().setRpEntityName("");
|
||||
getPolicyPage().clickSaveButton();
|
||||
AbstractPatternFlyAlert.waitUntilHidden();
|
||||
|
||||
rpEntityName = getPolicyPage().getRpEntityName();
|
||||
assertThat(rpEntityName, notNullValue());
|
||||
|
@ -128,6 +133,7 @@ public abstract class AbstractWebAuthnPolicySettingsTest extends AbstractConsole
|
|||
|
||||
getPolicyPage().setRpEntityId("rpId123");
|
||||
getPolicyPage().clickSaveButton();
|
||||
AbstractPatternFlyAlert.waitUntilHidden();
|
||||
|
||||
rpEntityId = getPolicyPage().getRpEntityId();
|
||||
assertThat(rpEntityId, notNullValue());
|
||||
|
|
Loading…
Reference in a new issue