Java 类org.openqa.selenium.support.ui.UnexpectedTagNameException 实例源码

项目:alex    文件:SelectAction.java   
@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();
    }
}
项目:seleniumtestsframework    文件:SelectList.java   
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"));
        }
    }
}
项目:seleniumtestsframework    文件:SelectList.java   
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"));
        }
    }
}
项目:automation-test-engine    文件:MyWebElement.java   
/**
 * 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);
        }
    }

}
项目:bandwidth-on-demand    文件:CreateVirtualPortPage.java   
public String getSelectedPhysicalResourceGroup() {
  try {
    return new Select(physicalResourceGroupSelect).getFirstSelectedOption().getText();
  }
  catch (UnexpectedTagNameException e) {
    WebElement element = physicalResourceGroupSelect.findElement(By.xpath(".."));
    return element.getText();
  }
}