Class WebDriverElementFinder


  • public class WebDriverElementFinder
    extends Object
    WebDriver Element Locator. Fully override the implementation of original ElementFinder. Note: This does not support ui locator.
    • Constructor Detail

      • WebDriverElementFinder

        public WebDriverElementFinder()
        Constructor.
    • Method Detail

      • convertToOptionLocatorWithParent

        @Deprecated
        public static String convertToOptionLocatorWithParent​(String parentLocator,
                                                              String optionLocator)
        Deprecated.
        Convert to option locator with parent.
        Parameters:
        parentLocator - parent locator.
        optionLocator - child option locator.
        Returns:
        option locator with parent.
      • getOptionHandler

        public OptionLocatorHandler getOptionHandler​(OptionLocator poptloc)
        Get option locator handler.
        Parameters:
        poptloc - option locator.
        Returns:
        option locator handler.
      • add

        public void add​(String strategyName,
                        String implementation)
        Add user defined handler of element finder.
        Parameters:
        strategyName - strategy name.
        implementation - JavaScript code.
      • findOptions

        public List<org.openqa.selenium.WebElement> findOptions​(org.openqa.selenium.WebElement element,
                                                                OptionLocator poptloc)
        Find "option" elements of specified option locator.
        Parameters:
        element - "select" element.
        poptloc - parsed option locator.
        Returns:
        list of found "option" elements.
      • findElements

        public List<org.openqa.selenium.WebElement> findElements​(org.openqa.selenium.WebDriver driver,
                                                                 Locator ploc,
                                                                 List<Locator> selectedFrameLocators)
        Find elements of specified locator.
        Parameters:
        driver - WebDriver.
        ploc - parsed locator.
        selectedFrameLocators - selected frame locators.
        Returns:
        list of found elements. (empty if no element)
      • findElements

        public List<org.openqa.selenium.WebElement> findElements​(org.openqa.selenium.WebDriver driver,
                                                                 Locator ploc)
        Find elements of specified locator.
        Parameters:
        driver - WebDriver.
        ploc - parsed locator.
        Returns:
        list of found elements. (empty if no element)
      • findElements

        public List<org.openqa.selenium.WebElement> findElements​(org.openqa.selenium.WebDriver driver,
                                                                 String locator)
        Find elements of specified locator.
        Parameters:
        driver - WebDriver.
        locator - locator.
        Returns:
        list of found elements. (empty if no element)
      • findElement

        public org.openqa.selenium.WebElement findElement​(org.openqa.selenium.WebDriver driver,
                                                          Locator ploc,
                                                          List<Locator> selectedFrameLocators)
        Find an element of specified locator.
        Parameters:
        driver - WebDriver.
        ploc - parsed locator.
        selectedFrameLocators - selected frame locators.
        Returns:
        found element.
        Throws:
        WebDriverElementFinder.ElementFinderNoSuchElementException - throw if element not found.
      • findElementWithTimeout

        public org.openqa.selenium.WebElement findElementWithTimeout​(org.openqa.selenium.WebDriver driver,
                                                                     Locator ploc,
                                                                     boolean isRetryable,
                                                                     int timeout)
        Find an element.
        Parameters:
        driver - WebDriver.
        ploc - parsed locator.
        isRetryable - retry finding an element. If false, this is the same as findElement(WebDriver, Locator).
        timeout - timeout (ms).
        Returns:
        found element.
        Throws:
        WebDriverElementFinder.ElementFinderNoSuchElementException - throw if element not found.
      • findElementWithTimeout

        public org.openqa.selenium.WebElement findElementWithTimeout​(org.openqa.selenium.WebDriver driver,
                                                                     String locator,
                                                                     boolean isRetryable,
                                                                     int timeout)
        Find an element.
        Parameters:
        driver - WebDriver.
        locator - locator.
        isRetryable - retry finding an element. If false, this is the same as findElement(WebDriver, Locator).
        timeout - timeout (ms).
        Returns:
        found element.
        Throws:
        WebDriverElementFinder.ElementFinderNoSuchElementException - throw if element not found.
      • selectFrame

        public void selectFrame​(org.openqa.selenium.WebDriver driver,
                                Locator ploc)
        Select frame or iframe.
        Parameters:
        driver - WebDriver.
        ploc - parsed locator to frame/iframe.
        Throws:
        org.openqa.selenium.NoSuchFrameException - If the frame cannot be found
      • selectFrame

        public void selectFrame​(org.openqa.selenium.WebDriver driver,
                                String locator)
        Select frame or iframe.
        Parameters:
        driver - WebDriver.
        locator - locator to frame/iframe.
      • getCurrentFrameLocators

        public List<Locator> getCurrentFrameLocators()
        Get copy of current frame locators.
        Returns:
        current frame locators.