Package org.openqa.selenium.htmlunit
Class HtmlUnitElementFinder.HtmlUnitElementLocator
java.lang.Object
org.openqa.selenium.htmlunit.HtmlUnitElementFinder.HtmlUnitElementLocator
- Direct Known Subclasses:
HtmlUnitElementFinder.FindByClassName,HtmlUnitElementFinder.FindByCssSelector,HtmlUnitElementFinder.FindByID,HtmlUnitElementFinder.FindByLinkText,HtmlUnitElementFinder.FindByName,HtmlUnitElementFinder.FindByPartialLinkText,HtmlUnitElementFinder.FindByRelativeLocator,HtmlUnitElementFinder.FindByTagName,HtmlUnitElementFinder.FindByXPath
- Enclosing class:
- HtmlUnitElementFinder
Base class for element locators used by
HtmlUnitElementFinder.
Provides common utilities for finding elements within a page or another element,
as well as methods for retrieving the last loaded page and extracting values from
By locators.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.openqa.selenium.WebElementfindElement(HtmlUnitDriver driver, org.openqa.selenium.By locator) Finds a single element on the given page using the provided locator.org.openqa.selenium.WebElementfindElement(HtmlUnitWebElement element, org.openqa.selenium.By locator) Finds a single element within a specificHtmlUnitWebElement.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.abstract List<org.openqa.selenium.WebElement>findElements(HtmlUnitWebElement element, org.openqa.selenium.By locator) Finds multiple elements within a specificHtmlUnitWebElement.protected SgmlPagegetLastPage(HtmlUnitDriver driver) Retrieves the last loadedSgmlPagefrom the driver.protected static org.openqa.selenium.By.RemotablegetRemotable(org.openqa.selenium.By locator) Converts aBylocator to aBy.Remotablelocator.protected static StringgetValue(org.openqa.selenium.By locator) Extracts the string value from a remotableBylocator.
-
Constructor Details
-
HtmlUnitElementLocator
public HtmlUnitElementLocator()
-
-
Method Details
-
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
NoSuchElementExceptionis thrown.- Parameters:
driver- the driver representing the browser/page contextlocator- 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 contextlocator- the locator strategy to use- Returns:
- a list of matching
WebElementobjects
-
findElement
public org.openqa.selenium.WebElement findElement(HtmlUnitWebElement element, org.openqa.selenium.By locator) Finds a single element within a specificHtmlUnitWebElement.If multiple elements match, only the first is returned. If no element is found, a
NoSuchElementExceptionis thrown.- Parameters:
element- the element within which to searchlocator- 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 specificHtmlUnitWebElement.- Parameters:
element- the element within which to searchlocator- the locator strategy to use- Returns:
- a list of matching
WebElementobjects
-
getRemotable
protected static org.openqa.selenium.By.Remotable getRemotable(org.openqa.selenium.By locator) Converts aBylocator to aBy.Remotablelocator.- Parameters:
locator- the locator to convert- Returns:
- the remotable locator
- Throws:
IllegalStateException- if the locator is not remotable
-
getLastPage
Retrieves the last loadedSgmlPagefrom 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
Extracts the string value from a remotableBylocator.- Parameters:
locator- the locator from which to extract the value- Returns:
- the string value of the locator
-