[KEYCLOAK-2697] Fix some UI tests stability
This commit is contained in:
parent
705a598ce6
commit
25363a91f9
6 changed files with 32 additions and 25 deletions
|
@ -1,6 +1,7 @@
|
||||||
package org.keycloak.testsuite.console.page.authentication;
|
package org.keycloak.testsuite.console.page.authentication;
|
||||||
|
|
||||||
import org.jboss.arquillian.graphene.findby.ByJQuery;
|
import org.jboss.arquillian.graphene.findby.ByJQuery;
|
||||||
|
import org.keycloak.testsuite.page.Form;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
@ -14,6 +15,7 @@ import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
|
||||||
* @author Petr Mensik
|
* @author Petr Mensik
|
||||||
* @author tkyjovsk
|
* @author tkyjovsk
|
||||||
* @author mhajas
|
* @author mhajas
|
||||||
|
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
||||||
*/
|
*/
|
||||||
public class PasswordPolicy extends Authentication {
|
public class PasswordPolicy extends Authentication {
|
||||||
|
|
||||||
|
@ -28,10 +30,10 @@ public class PasswordPolicy extends Authentication {
|
||||||
@FindBy(tagName = "select")
|
@FindBy(tagName = "select")
|
||||||
private WebElement addPolicySelectElement;
|
private WebElement addPolicySelectElement;
|
||||||
|
|
||||||
@FindBy(css = "tr.ng-scope")
|
@FindBy(tagName = "table")
|
||||||
private List<WebElement> allRows;
|
private WebElement table;
|
||||||
|
|
||||||
public void addPolicy(PasswordPolicy.Type policy, String value) {
|
public void addPolicy(Type policy, String value) {
|
||||||
waitUntilElement(addPolicySelectElement).is().present();
|
waitUntilElement(addPolicySelectElement).is().present();
|
||||||
addPolicySelect.selectByVisibleText(policy.getName());
|
addPolicySelect.selectByVisibleText(policy.getName());
|
||||||
setPolicyValue(policy, value);
|
setPolicyValue(policy, value);
|
||||||
|
@ -39,45 +41,36 @@ public class PasswordPolicy extends Authentication {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addPolicy(PasswordPolicy.Type policy, int value) {
|
public void addPolicy(Type policy, int value) {
|
||||||
addPolicy(policy, String.valueOf(value));
|
addPolicy(policy, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPolicy(PasswordPolicy.Type policy) {
|
public void addPolicy(Type policy) {
|
||||||
addPolicySelect.selectByVisibleText(policy.getName());
|
addPolicySelect.selectByVisibleText(policy.getName());
|
||||||
primaryButton.click();
|
primaryButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePolicy(PasswordPolicy.Type policy) {
|
public void removePolicy(Type policy) {
|
||||||
int policyInputLocation = findPolicy(policy);
|
getPolicyRow(policy).findElement(By.cssSelector("td.kc-action-cell")).click();
|
||||||
allRows.get(policyInputLocation).findElements(By.tagName("button")).get(0).click();
|
|
||||||
primaryButton.click();
|
primaryButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editPolicy(PasswordPolicy.Type policy, int value) {
|
public void editPolicy(Type policy, int value) {
|
||||||
editPolicy(policy, String.valueOf(value));
|
editPolicy(policy, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editPolicy(PasswordPolicy.Type policy, String value) {
|
public void editPolicy(Type policy, String value) {
|
||||||
setPolicyValue(policy, value);
|
setPolicyValue(policy, value);
|
||||||
primaryButton.click();
|
primaryButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPolicyValue(PasswordPolicy.Type policy, String value) {
|
private void setPolicyValue(Type policy, String value) {
|
||||||
int policyInputLocation = findPolicy(policy);
|
WebElement input = getPolicyRow(policy).findElement(By.tagName("input"));
|
||||||
WebElement input = allRows.get(policyInputLocation).findElement(By.tagName("input"));
|
Form.setInputValue(input, value);
|
||||||
input.clear();
|
|
||||||
input.sendKeys(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int findPolicy(PasswordPolicy.Type policy) {
|
private WebElement getPolicyRow(Type policy) {
|
||||||
for (int i = 0; i < allRows.size(); i++) {
|
return table.findElement(By.xpath("//tr[td[text()='" + policy.getName() + "']]"));
|
||||||
String policyName = allRows.get(i).findElement(ByJQuery.selector("td:eq(0)")).getText();
|
|
||||||
if (policyName.equals(policy.getName())) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.keycloak.testsuite.console.page.authentication;
|
package org.keycloak.testsuite.console.page.authentication;
|
||||||
|
|
||||||
|
import org.keycloak.testsuite.util.WaitUtils;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
@ -28,6 +29,8 @@ public class RequiredActions extends Authentication {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setRequiredActionValue(String id, boolean value) {
|
private void setRequiredActionValue(String id, boolean value) {
|
||||||
|
WaitUtils.waitUntilElement(requiredActionTable).is().present();
|
||||||
|
|
||||||
WebElement checkbox = requiredActionTable.findElement(By.id(id));
|
WebElement checkbox = requiredActionTable.findElement(By.id(id));
|
||||||
|
|
||||||
if (checkbox.isSelected() != value) {
|
if (checkbox.isSelected() != value) {
|
||||||
|
|
|
@ -191,6 +191,10 @@ public class LdapUserProviderForm extends Form {
|
||||||
vendorSelect.selectByVisibleText(vendor);
|
vendorSelect.selectByVisibleText(vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void selectVendor(int index) {
|
||||||
|
vendorSelect.selectByIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getVendors() {
|
public List<String> getVendors() {
|
||||||
waitUntilElement(By.id("vendor")).is().present();
|
waitUntilElement(By.id("vendor")).is().present();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.keycloak.testsuite.console.page.realm;
|
package org.keycloak.testsuite.console.page.realm;
|
||||||
|
|
||||||
import org.keycloak.testsuite.console.page.AdminConsoleRealm;
|
import org.keycloak.testsuite.console.page.AdminConsoleRealm;
|
||||||
|
import org.keycloak.testsuite.util.WaitUtils;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
|
||||||
|
@ -11,11 +13,14 @@ import static org.keycloak.testsuite.util.WaitUtils.*;
|
||||||
* @author tkyjovsk
|
* @author tkyjovsk
|
||||||
*/
|
*/
|
||||||
public class RealmSettings extends AdminConsoleRealm {
|
public class RealmSettings extends AdminConsoleRealm {
|
||||||
|
private static final String navTabsClassName = "nav-tabs";
|
||||||
|
|
||||||
@FindBy(className = "nav-tabs")
|
|
||||||
|
@FindBy(className = navTabsClassName)
|
||||||
private RealmTabs realmTabs;
|
private RealmTabs realmTabs;
|
||||||
|
|
||||||
public RealmTabs tabs() {
|
public RealmTabs tabs() {
|
||||||
|
waitUntilElement(By.className(navTabsClassName)).is().present();
|
||||||
return realmTabs;
|
return realmTabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicy;
|
||||||
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.Digits;
|
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.Digits;
|
||||||
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.OTPHashAlg;
|
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.OTPHashAlg;
|
||||||
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.OTPType;
|
import org.keycloak.testsuite.console.page.authentication.otppolicy.OTPPolicyForm.OTPType;
|
||||||
|
import org.keycloak.testsuite.util.WaitUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -45,6 +46,7 @@ public class OTPPolicyTest extends AbstractConsoleTest {
|
||||||
@Before
|
@Before
|
||||||
public void beforeOTPPolicyTest() {
|
public void beforeOTPPolicyTest() {
|
||||||
otpPolicyPage.navigateTo();
|
otpPolicyPage.navigateTo();
|
||||||
|
WaitUtils.pause(1000); // wait for the form to fully render
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class LdapUserFederationTest extends AbstractConsoleTest {
|
||||||
@Test
|
@Test
|
||||||
public void testConnection() throws Exception {
|
public void testConnection() throws Exception {
|
||||||
createLdapUserProvider.navigateTo();
|
createLdapUserProvider.navigateTo();
|
||||||
createLdapUserProvider.form().selectVendor("Other");
|
createLdapUserProvider.form().selectVendor(1);
|
||||||
createLdapUserProvider.form().setConsoleDisplayNameInput("ldap");
|
createLdapUserProvider.form().setConsoleDisplayNameInput("ldap");
|
||||||
createLdapUserProvider.form().selectEditMode(WRITABLE);
|
createLdapUserProvider.form().selectEditMode(WRITABLE);
|
||||||
createLdapUserProvider.form().setLdapConnectionUrlInput("ldap://localhost:10389");
|
createLdapUserProvider.form().setLdapConnectionUrlInput("ldap://localhost:10389");
|
||||||
|
|
Loading…
Reference in a new issue