use of org.openqa.selenium.support.ui.UnexpectedTagNameException in project alex by LearnLib.
the class SelectAction method execute.
@Override
public ExecuteResult execute(WebSiteConnector connector) {
final WebElementLocator nodeWithVariables = new WebElementLocator(insertVariableValues(node.getSelector()), node.getType());
try {
final String valueWithVariables = insertVariableValues(value);
final WebElement selectElement = connector.getElement(nodeWithVariables);
final Select select = new Select(selectElement);
switch(selectBy) {
case VALUE:
select.selectByValue(valueWithVariables);
break;
case TEXT:
select.selectByVisibleText(valueWithVariables);
break;
case INDEX:
select.selectByIndex(Integer.parseInt(value));
break;
default:
select.selectByIndex(0);
break;
}
logger.info(LoggerMarkers.LEARNER, "Selected '{}' of '{}' by '{}'.", value, nodeWithVariables, selectBy);
return getSuccessOutput();
} catch (NoSuchElementException | NumberFormatException | UnexpectedTagNameException e) {
logger.info(LoggerMarkers.LEARNER, "Could not select '{}' of '{}' by '{}'.", value, nodeWithVariables, selectBy, e);
return getFailedOutput();
}
}
Aggregations