@Override
    public List<WebElement> findElementsBy(final SearchContext context) {

      List<WebElement> matchingElems = null;

      final List<WebElement> tagElements = context.findElements(By.tagName(this.tagName));

      for (final WebElement e : tagElements) {
        // does this WebElement have the attributes that we need!

        if (elementHasExpectedAttributes(e, this.requiredAttributes)) {

          if (matchingElems == null) {
            matchingElems = new ArrayList<WebElement>();
          }
          matchingElems.add(e);
        }
      }

      if (matchingElems != null && matchingElems.size() < this.minimumExpected) {
        logger.info(
            "expecting at least "
                + this.minimumExpected
                + " matching elems, found only "
                + matchingElems.size()
                + " this time around");
        // we haven't found enough, clear out
        matchingElems = null;
      }

      return matchingElems;
    }
Пример #2
0
 public static boolean isVisible(SearchContext searchContext, By by) {
   try {
     boolean result = false;
     result = searchContext.findElement(by).isDisplayed();
     return result;
   } catch (NoSuchElementException ex) {
     return false;
   }
 }
Пример #3
0
 public static List<WebElement> findVisibleElements(By searchElements, SearchContext context) {
   List<WebElement> visibleElements = new java.util.ArrayList<WebElement>();
   for (WebElement element : context.findElements(searchElements)) {
     if (element.isDisplayed()) {
       visibleElements.add(element);
     }
   }
   return visibleElements;
 }
    /*
     * (non-Javadoc)
     *
     * @see
     * org.openqa.selenium.By#findElements(org.openqa.selenium.SearchContext
     * )
     */
    @Override
    public List<WebElement> findElementsBy(final SearchContext context) {

      List<WebElement> matchingElems = null;

      final List<WebElement> elems = context.findElements(By.id(this.id));
      if (elems != null) {
        for (final WebElement e : elems) {

          if (e.getText() != null && e.getText().contains(this.text)) {

            if (matchingElems == null) {
              matchingElems = new ArrayList<WebElement>();
            }
            matchingElems.add(e);
          }
        }
      }

      return matchingElems;
    }
    /*
     * (non-Javadoc)
     *
     * @see
     * org.openqa.selenium.By#findElements(org.openqa.selenium.SearchContext
     * )
     */
    @Override
    public List<WebElement> findElementsBy(final SearchContext context) {

      List<WebElement> matchingElems = null;

      final List<WebElement> elems = context.findElements(By.tagName(this.tag));
      if (elems != null) {
        for (final WebElement e : elems) {

          if (this.stringMatcher.matches(e.getText())) {

            if (matchingElems == null) {
              matchingElems = new ArrayList<WebElement>();
            }
            matchingElems.add(e);
          }
        }
      }

      return matchingElems;
    }
    /*
     * (non-Javadoc)
     *
     * @see
     * org.openqa.selenium.By#findElements(org.openqa.selenium.SearchContext
     * )
     */
    @Override
    public List<WebElement> findElementsBy(final SearchContext context) {

      List<WebElement> matchingElems = null;

      final List<WebElement> elems = context.findElements(By.id(this.id));
      if (elems != null) {
        for (final WebElement e : elems) {

          if ((this.caseSensitive && this.text.equals(e.getText()))
              || (!this.caseSensitive && this.text.equalsIgnoreCase(e.getText()))) {

            if (matchingElems == null) {
              matchingElems = new ArrayList<WebElement>();
            }
            matchingElems.add(e);
          }
        }
      }

      return matchingElems;
    }
Пример #7
0
 protected ElementBase(SearchContext host, By locator) {
   this.host = host;
   this.locator = locator;
   wrappedElement = host.findElement(locator);
 }
Пример #8
0
 @Override
 public Table apply(SearchContext context) {
   return new SimpleTable(context.findElement(by));
 }
Пример #9
0
 protected String getTime(SearchContext searchContext) {
   String time = searchContext.findElement(REQUEST_TIME).getText();
   return time;
 }
Пример #10
0
 private WebElement findWebElementByIdentification() {
   SearchContext searchContext = model.getSearchContext();
   return searchContext.findElement(model.getSeleniumBy());
 }
Пример #11
0
 public WebElement findElement(By by) {
   findPlugins().beforeFindElement(browser, by);
   WebElement result = UiObject.wrap(searchContext.findElement(by), by);
   findPlugins().afterFindElement(browser, by, result);
   return result;
 }
Пример #12
0
 public List<WebElement> findElements(By by) {
   findPlugins().beforeFindElement(browser, by);
   List<WebElement> result = UiObject.wrapAll(searchContext.findElements(by), by);
   findPlugins().afterFindElements(browser, by, result);
   return result;
 }
Пример #13
0
 public List<WebElement> find(By by, DriverScope scope) {
   SearchContext context = seleniumScope(scope);
   return context.findElements(by);
 }
Пример #14
0
 @Override
 public WebElement findElement(By by) {
   return element.findElement(by);
 }
Пример #15
0
 @Override
 public List<WebElement> findElements(By by) {
   return element.findElements(by);
 }