org.openqa.selenium.By#findElement ( )源码实例Demo

下面列出了org.openqa.selenium.By#findElement ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hsac-fitnesse-fixtures   文件: BrowserTest.java
protected boolean clickSelectOption(WebElement element, String optionValue) {
    boolean result = false;
    if (element != null) {
        if (isSelect(element)) {
            optionValue = cleanupValue(optionValue);
            By optionBy = new OptionBy(optionValue);
            WebElement option = optionBy.findElement(element);
            result = clickSelectOption(element, option);
        }
    }
    return result;
}
 
/**
 * Converts By to Function returning first result (or null).
 * @param by by to convert.
 * @return function returning first result of by.
 */
public static <T extends WebElement> Function<SearchContext, T> byToFunction(By by) {
    Function<SearchContext, T> function;
    if (by instanceof SingleElementOrNullBy) {
        // will not throw exception, but return null when no element is found
        function = sc -> (T) by.findElement(sc);
    } else {
        function = sc -> {
            // single element case will throw exception when no element is found
            List elements = by.findElements(sc);
            return (elements != null && !elements.isEmpty())? (T) elements.get(0) : null;
        };
    }
    return function;
}
 
源代码3 项目: hsac-fitnesse-fixtures   文件: FirstElementBy.java
public static <T extends WebElement> T getWebElement(By by, SearchContext context) {
    T byResult;
    if (by instanceof SingleElementOrNullBy) {
        byResult = (T) by.findElement(context);
    } else {
        byResult = BestMatchBy.findElement(by, context);
    }
    return byResult;
}
 
源代码4 项目: selenium   文件: RemoteWebDriver.java
@Override
public WebElement findElement(By locator) {
  if (locator instanceof By.StandardLocator) {
    return ((By.StandardLocator) locator).findElement(this, this::findElement);
  } else {
    return locator.findElement(this);
  }
}
 
源代码5 项目: selenium   文件: RemoteWebElement.java
@Override
public WebElement findElement(By by) {
  if (by instanceof By.StandardLocator) {
    return ((By.StandardLocator) by).findElement(this, this::findElement);
  } else {
    return by.findElement(this);
  }
}