use of org.openqa.selenium.By.tagName in project keycloak by keycloak.
the class GroupPolicyForm method populate.
public void populate(GroupPolicyRepresentation expected, boolean save) {
UIUtils.setTextInputValue(name, expected.getName());
UIUtils.setTextInputValue(description, expected.getDescription());
UIUtils.setTextInputValue(groupsClaim, expected.getGroupsClaim());
logic.selectByValue(expected.getLogic().name());
for (GroupPolicyRepresentation.GroupDefinition definition : toRepresentation().getGroups()) {
boolean isExpected = false;
for (GroupPolicyRepresentation.GroupDefinition expectedDef : expected.getGroups()) {
if (definition.getPath().equals(expectedDef.getPath())) {
isExpected = true;
break;
}
}
if (!isExpected) {
unselect(definition.getPath());
}
}
for (GroupPolicyRepresentation.GroupDefinition definition : expected.getGroups()) {
String path = definition.getPath();
String groupName = path.substring(path.lastIndexOf('/') + 1);
WebElement element = driver.findElement(By.xpath("//span[text()='" + groupName + "']"));
element.click();
waitUntilElement(selectGroupButton).is().enabled();
selectGroupButton.click();
driver.findElements(By.xpath("(//table[@id='selected-groups'])/tbody/tr")).stream().filter(webElement -> webElement.findElements(tagName("td")).size() > 1).map(webElement -> webElement.findElements(tagName("td"))).filter(tds -> UIUtils.getTextFromElement(tds.get(0)).equals(definition.getPath())).forEach(tds -> {
if (!tds.get(1).findElement(By.tagName("input")).isSelected()) {
if (definition.isExtendChildren()) {
tds.get(1).findElement(By.tagName("input")).click();
}
} else {
if (!definition.isExtendChildren() && tds.get(1).findElement(By.tagName("input")).isSelected()) {
tds.get(1).findElement(By.tagName("input")).click();
}
}
});
}
if (save) {
save();
}
}
Aggregations