From 3dbf5ee389cb17baa60f7aa1fea50fbdb1831840 Mon Sep 17 00:00:00 2001 From: Vaclav Muzikar Date: Tue, 5 Apr 2016 10:13:40 +0200 Subject: [PATCH] KEYCLOAK-2745 More UI tests stabilization --- .../console/page/fragment/ModalDialog.java | 2 +- .../org/keycloak/testsuite/page/Form.java | 1 + .../page/federation/LdapUserProviderForm.java | 14 ++------- .../console/authentication/OTPPolicyTest.java | 31 +++++++------------ .../realm/InternationalizationTest.java | 1 + 5 files changed, 17 insertions(+), 32 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/ModalDialog.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/ModalDialog.java index 8159d34ef9..6dc90073b8 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/ModalDialog.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/fragment/ModalDialog.java @@ -53,7 +53,7 @@ public class ModalDialog { waitUntilElement(deleteButton).is().present(); deleteButton.click(); waitUntilElement(root).is().not().present(); - pause(100); + pause(200); } public void cancel() { diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/page/Form.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/page/Form.java index f3de88db18..8f3232b54d 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/page/Form.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/page/Form.java @@ -45,6 +45,7 @@ public class Form { public void save() { // guardAjax(save).click(); + waitUntilElement(save).is().present(); save.click(); } diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/federation/LdapUserProviderForm.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/federation/LdapUserProviderForm.java index 88e207cee3..2b77ee9c40 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/federation/LdapUserProviderForm.java +++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/federation/LdapUserProviderForm.java @@ -192,6 +192,7 @@ public class LdapUserProviderForm extends Form { } public void selectVendor(int index) { + waitUntilElement(By.id("vendor")).is().present(); vendorSelect.selectByIndex(index); } @@ -233,20 +234,11 @@ public class LdapUserProviderForm extends Form { } public void setAccountAfterPasswordUpdateEnabled(boolean enabled) { - if ((!enableAccountAfterPasswordUpdate.isOn() && enabled) - || !enabled && enableAccountAfterPasswordUpdate.isOn()) { - driver.findElement(By - .xpath("//div[contains(@class,'onoffswitch') and ./input[@id='userAccountControlsAfterPasswordUpdate']]")) - .findElements(By.tagName("span")).get(0).click(); - } + enableAccountAfterPasswordUpdate.setOn(enabled); } public void setAllowKerberosAuthEnabled(boolean enabled) { - if ((!allowKerberosAuth.isOn() && enabled) || !enabled && allowKerberosAuth.isOn()) { - driver.findElement( - By.xpath("//div[contains(@class,'onoffswitch') and ./input[@id='allowKerberosAuthentication']]")) - .findElements(By.tagName("span")).get(0).click(); - } + allowKerberosAuth.setOn(enabled); } public void setDebugEnabled(boolean debugEnabled) { diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authentication/OTPPolicyTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authentication/OTPPolicyTest.java index 73173a7f22..1f2e22fc20 100644 --- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authentication/OTPPolicyTest.java +++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/authentication/OTPPolicyTest.java @@ -52,7 +52,7 @@ public class OTPPolicyTest extends AbstractConsoleTest { @Test public void otpPolicyTest() { otpPolicyPage.form().setValues(OTPType.COUNTER_BASED, OTPHashAlg.SHA256, Digits.EIGHT, "10", "50"); - assertEquals("Success! Your changes have been saved to the realm.", otpPolicyPage.getSuccessMessage()); + assertAlertSuccess(); RealmRepresentation realm = testRealmResource().toRepresentation(); assertEquals("hotp", realm.getOtpPolicyType()); @@ -62,7 +62,7 @@ public class OTPPolicyTest extends AbstractConsoleTest { assertEquals(Integer.valueOf(50), realm.getOtpPolicyInitialCounter()); otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA512, Digits.EIGHT, "10", "40"); - assertEquals("Success! Your changes have been saved to the realm.", otpPolicyPage.getSuccessMessage()); + assertAlertSuccess(); realm = testRealmResource().toRepresentation(); assertEquals(Integer.valueOf(40), realm.getOtpPolicyPeriod()); @@ -71,54 +71,45 @@ public class OTPPolicyTest extends AbstractConsoleTest { @Test public void invalidValuesTest() { otpPolicyPage.form().setValues(OTPType.TIME_BASED, OTPHashAlg.SHA1, Digits.SIX, "", "30"); - assertEquals("Error! Missing or invalid field(s). Please verify the fields in red.", otpPolicyPage.getErrorMessage()); - otpPolicyPage.closeNotification(); + assertAlertDanger(); otpPolicyPage.navigateTo();// workaround: input.clear() doesn't work when