Class FindByUtils

java.lang.Object
uk.co.evoco.webdriver.utils.FindByUtils

public final class FindByUtils
extends java.lang.Object
Utilities class providing support methods for locating elements in more dynamic ways than the standard out of the box location methods provided by Selenium
  • Constructor Summary

    Constructors 
    Constructor Description
    FindByUtils()  
  • Method Summary

    Modifier and Type Method Description
    static org.openqa.selenium.WebElement byIdOrName​(org.openqa.selenium.WebDriver webDriver, java.lang.String idOrName)
    Finds elements by either the HTML name or id attribute using the given selector text
    static org.openqa.selenium.WebElement multipleLocatorMatchGetDisplayed​(org.openqa.selenium.WebDriver webDriver, org.openqa.selenium.By locator)
    Finds the first element that is displayed with given locator.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • multipleLocatorMatchGetDisplayed

      public static org.openqa.selenium.WebElement multipleLocatorMatchGetDisplayed​(org.openqa.selenium.WebDriver webDriver, org.openqa.selenium.By locator) throws org.openqa.selenium.WebDriverException
      Finds the first element that is displayed with given locator. Useful for instances where there are multiple elements on the DOM with the same locator and one (or more) of them are hidden (e.g. used in mobile layouts or hold a different z-index given some other element is present)
      Parameters:
      webDriver - active WebDriver instance
      locator - selector for target WebElement
      Returns:
      active WebElement, already located
      Throws:
      org.openqa.selenium.WebDriverException
    • byIdOrName

      public static org.openqa.selenium.WebElement byIdOrName​(org.openqa.selenium.WebDriver webDriver, java.lang.String idOrName)
      Finds elements by either the HTML name or id attribute using the given selector text
      Parameters:
      webDriver - active WebDriver instance
      idOrName - the variable locator
      Returns:
      active WebElement, already located