@Override public ExecuteResult execute(WebSiteConnector connector) { try { String valueWithVariables = insertVariableValues(value); node.setSelector(insertVariableValues(node.getSelector())); WebElement selectElement = connector.getElement(node); 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(getValue())); break; default: select.selectByIndex(0); break; } LOGGER.info(LEARNER_MARKER, "Selected '{}' of '{}' by '{}' (ignoreFailure: {}, negated: {}).", value, node, selectBy, ignoreFailure, negated); return getSuccessOutput(); } catch (NoSuchElementException | NumberFormatException | UnexpectedTagNameException e) { LOGGER.info(LEARNER_MARKER, "Could not select '{}' of '{}' by '{}' (ignoreFailure: {}, negated: {}).", value, node, selectBy, ignoreFailure, negated, e); return getFailedOutput(); } }
protected void findElement() { driver = WebUIDriver.getWebDriver(); element = driver.findElement(this.getBy()); try { select = getNewSelectElement(element); options = select.getOptions(); } catch (UnexpectedTagNameException e) { if (element.getTagName().equalsIgnoreCase("ul")) { options = element.findElements(By.tagName("li")); } } }
public void init() { super.init(); try { select = getNewSelectElement(element); options = select.getOptions(); } catch (UnexpectedTagNameException e) { if (element.getTagName().equalsIgnoreCase("ul")) { options = element.findElements(By.tagName("li")); } } }
/** * Do action. * @throws BrowserUnexpectedException * @throws NoSuchElementException */ public void doAction() throws NoSuchElementException, BrowserUnexpectedException { final ITestObjectAction<T> testObjectAction2 = testObjectAction; if (testObjectAction2 == null) { throw GlobalUtils.createNotInitializedException("test object action."); } else { try { testObjectAction2.doAction(testObjectFinder.doFind(getMyWd())); } catch (UnexpectedTagNameException ute) { throw new NoSuchElementException("Html element found by ate has different tag name.", ute); } } }
public String getSelectedPhysicalResourceGroup() { try { return new Select(physicalResourceGroupSelect).getFirstSelectedOption().getText(); } catch (UnexpectedTagNameException e) { WebElement element = physicalResourceGroupSelect.findElement(By.xpath("..")); return element.getText(); } }