Class HtmlUnitElementFinder.HtmlUnitElementLocator

    • Constructor Detail

      • HtmlUnitElementLocator

        public HtmlUnitElementLocator()
    • Method Detail

      • findElement

        public org.openqa.selenium.WebElement findElement​(HtmlUnitDriver driver,
                                                          org.openqa.selenium.By locator)
        Finds a single element on the given page using the provided locator.

        If multiple elements match, only the first is returned. If no element is found, a NoSuchElementException is thrown.

        Parameters:
        driver - the driver representing the browser/page context
        locator - the locator strategy to use
        Returns:
        the first matching WebElement
        Throws:
        org.openqa.selenium.NoSuchElementException - if no element matches the locator
      • findElements

        public abstract List<org.openqa.selenium.WebElement> findElements​(HtmlUnitDriver driver,
                                                                          org.openqa.selenium.By locator)
        Finds multiple elements on the given page using the provided locator.
        Parameters:
        driver - the driver representing the browser/page context
        locator - the locator strategy to use
        Returns:
        a list of matching WebElement objects
      • findElement

        public org.openqa.selenium.WebElement findElement​(HtmlUnitWebElement element,
                                                          org.openqa.selenium.By locator)
        Finds a single element within a specific HtmlUnitWebElement.

        If multiple elements match, only the first is returned. If no element is found, a NoSuchElementException is thrown.

        Parameters:
        element - the element within which to search
        locator - the locator strategy to use
        Returns:
        the first matching WebElement
        Throws:
        org.openqa.selenium.NoSuchElementException - if no element matches the locator
      • findElements

        public abstract List<org.openqa.selenium.WebElement> findElements​(HtmlUnitWebElement element,
                                                                          org.openqa.selenium.By locator)
        Finds multiple elements within a specific HtmlUnitWebElement.
        Parameters:
        element - the element within which to search
        locator - the locator strategy to use
        Returns:
        a list of matching WebElement objects
      • getRemotable

        protected static org.openqa.selenium.By.Remotable getRemotable​(org.openqa.selenium.By locator)
        Converts a By locator to a By.Remotable locator.
        Parameters:
        locator - the locator to convert
        Returns:
        the remotable locator
        Throws:
        IllegalStateException - if the locator is not remotable
      • getLastPage

        protected SgmlPage getLastPage​(HtmlUnitDriver driver)
        Retrieves the last loaded SgmlPage from the driver.
        Parameters:
        driver - the driver representing the browser/page context
        Returns:
        the last loaded SgmlPage
        Throws:
        IllegalStateException - if the current page is not an SgmlPage
      • getValue

        protected static String getValue​(org.openqa.selenium.By locator)
        Extracts the string value from a remotable By locator.
        Parameters:
        locator - the locator from which to extract the value
        Returns:
        the string value of the locator