KEYCLOAK-8792 Stabilize and fix Admin Console UI tests for RH-SSO
This commit is contained in:
parent
f5ae76d8e3
commit
6cee8b126b
5 changed files with 19 additions and 14 deletions
|
@ -31,6 +31,7 @@ import java.util.Set;
|
|||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
||||
import static org.keycloak.testsuite.util.WaitUtils.pause;
|
||||
import static org.keycloak.testsuite.util.WaitUtils.waitForPageToLoad;
|
||||
|
||||
|
@ -93,7 +94,7 @@ public abstract class AbstractMultipleSelect2<R> {
|
|||
|
||||
for (WebElement result : result) {
|
||||
if (result.getText().equalsIgnoreCase(id)) {
|
||||
result.click();
|
||||
clickLink(result);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.openqa.selenium.NoSuchElementException;
|
|||
import org.openqa.selenium.TimeoutException;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
import org.openqa.selenium.safari.SafariDriver;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
|
@ -62,6 +63,13 @@ public final class UIUtils {
|
|||
public static void clickLink(WebElement element) {
|
||||
WebDriver driver = getCurrentDriver();
|
||||
|
||||
// Sometimes at some weird specific conditions, Firefox fail to click an element
|
||||
// because the element is at the edge of the view and need to be scrolled on "manually" (normally the driver
|
||||
// should do this automatically)
|
||||
if (driver instanceof FirefoxDriver) {
|
||||
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
|
||||
}
|
||||
|
||||
if (driver instanceof SafariDriver && !element.isDisplayed()) { // Safari sometimes thinks an element is not visible
|
||||
// even though it is. In this case we just move the cursor and click.
|
||||
performOperationWithPageReload(() -> new Actions(driver).click(element).perform());
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.keycloak.testsuite.util.UIUtils.clickLink;
|
||||
import static org.keycloak.testsuite.util.UIUtils.getTextFromElement;
|
||||
import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;
|
||||
|
||||
|
@ -90,7 +91,7 @@ public class RoleCompositeRoles extends Form {
|
|||
select.selectByVisibleText(role);
|
||||
}
|
||||
}
|
||||
button.click();
|
||||
clickLink(button);
|
||||
}
|
||||
|
||||
public void addRealmRole(String role) {
|
||||
|
@ -110,7 +111,7 @@ public class RoleCompositeRoles extends Form {
|
|||
}
|
||||
}
|
||||
waitUntilElement(button).is().enabled();
|
||||
button.click();
|
||||
clickLink(button);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,14 +145,14 @@ public class RoleCompositeRoles extends Form {
|
|||
waitUntilElement(By.id("available")).is().present();
|
||||
for (String role : roles) {
|
||||
availableRealmRolesSelect.selectByVisibleText(role);
|
||||
addSelectedRealmRolesButton.click();
|
||||
clickLink(addSelectedRealmRolesButton);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAssignedRole(String role) {
|
||||
waitUntilElement(By.id("assigned")).is().present();
|
||||
assignedRealmRolesSelect.selectByVisibleText(role);
|
||||
removeSelectedRealmRolesButton.click();
|
||||
clickLink(removeSelectedRealmRolesButton);
|
||||
}
|
||||
|
||||
public boolean isAssignedRole(String role) {
|
||||
|
@ -173,14 +174,14 @@ public class RoleCompositeRoles extends Form {
|
|||
waitUntilElement(By.id("available-client")).is().present();
|
||||
for (String role : roles) {
|
||||
availableClientRolesSelect.selectByVisibleText(role);
|
||||
addSelectedClientRolesButton.click();
|
||||
clickLink(addSelectedClientRolesButton);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAssignedClientRole(String client) {
|
||||
waitUntilElement(By.id("assigned-client")).is().present();
|
||||
assignedClientRolesSelect.selectByVisibleText(client);
|
||||
removeSelectedClientRolesButton.click();
|
||||
clickLink(removeSelectedClientRolesButton);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull;
|
|||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -33,7 +32,6 @@ import org.keycloak.admin.client.resource.RolePoliciesResource;
|
|||
import org.keycloak.admin.client.resource.RolesResource;
|
||||
import org.keycloak.admin.client.resource.UsersResource;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.common.Version;
|
||||
import org.keycloak.representations.idm.RoleRepresentation;
|
||||
import org.keycloak.representations.idm.authorization.AggregatePolicyRepresentation;
|
||||
import org.keycloak.representations.idm.authorization.ClientPolicyRepresentation;
|
||||
|
@ -44,9 +42,7 @@ import org.keycloak.representations.idm.authorization.RolePolicyRepresentation;
|
|||
import org.keycloak.representations.idm.authorization.RulePolicyRepresentation;
|
||||
import org.keycloak.representations.idm.authorization.TimePolicyRepresentation;
|
||||
import org.keycloak.representations.idm.authorization.UserPolicyRepresentation;
|
||||
import org.keycloak.testsuite.admin.ApiUtil;
|
||||
import org.keycloak.testsuite.console.page.clients.authorization.policy.AggregatePolicy;
|
||||
import org.keycloak.testsuite.console.page.clients.authorization.policy.UserPolicy;
|
||||
import org.keycloak.testsuite.util.ClientBuilder;
|
||||
import org.keycloak.testsuite.util.GroupBuilder;
|
||||
import org.keycloak.testsuite.util.UserBuilder;
|
||||
|
@ -239,7 +235,7 @@ public class AggregatePolicyManagementTest extends AbstractAuthorizationSettings
|
|||
rulePolicy.setDescription("description");
|
||||
rulePolicy.setArtifactGroupId("org.keycloak.testsuite");
|
||||
rulePolicy.setArtifactId("photoz-authz-policy");
|
||||
rulePolicy.setArtifactVersion(Version.VERSION);
|
||||
rulePolicy.setArtifactVersion(System.getProperty("project.version"));
|
||||
rulePolicy.setModuleName("PhotozAuthzOwnerPolicy");
|
||||
rulePolicy.setSessionName("MainOwnerSession");
|
||||
rulePolicy.setScannerPeriod("1");
|
||||
|
|
|
@ -21,7 +21,6 @@ import static org.junit.Assert.assertNull;
|
|||
|
||||
import org.junit.Test;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.common.Version;
|
||||
import org.keycloak.representations.idm.authorization.Logic;
|
||||
import org.keycloak.representations.idm.authorization.RulePolicyRepresentation;
|
||||
import org.keycloak.testsuite.ProfileAssume;
|
||||
|
@ -95,7 +94,7 @@ public class RulePolicyManagementTest extends AbstractAuthorizationSettingsTest
|
|||
expected.setDescription("description");
|
||||
expected.setArtifactGroupId("org.keycloak.testsuite");
|
||||
expected.setArtifactId("photoz-authz-policy");
|
||||
expected.setArtifactVersion(Version.VERSION);
|
||||
expected.setArtifactVersion(System.getProperty("project.version"));
|
||||
expected.setModuleName("PhotozAuthzOwnerPolicy");
|
||||
expected.setSessionName("MainOwnerSession");
|
||||
expected.setScannerPeriod("1");
|
||||
|
|
Loading…
Reference in a new issue