public class HtmlUnitWebElement extends java.lang.Object implements WrapsDriver, FindsById, FindsByLinkText, FindsByXPath, FindsByTagName, FindsByCssSelector, Locatable, WebElement
Modifier and Type | Field and Description |
---|---|
protected com.gargoylesoftware.htmlunit.html.DomElement |
element |
protected HtmlUnitDriver |
parent |
Constructor and Description |
---|
HtmlUnitWebElement(HtmlUnitDriver parent,
com.gargoylesoftware.htmlunit.html.DomElement element) |
Modifier and Type | Method and Description |
---|---|
protected void |
assertElementNotStale() |
void |
clear()
If this element is a text entry element, this will clear the value.
|
void |
click()
Click this element.
|
boolean |
equals(java.lang.Object obj) |
WebElement |
findElement(By by)
Find the first
WebElement using the given method. |
WebElement |
findElementByCssSelector(java.lang.String using) |
WebElement |
findElementById(java.lang.String id) |
WebElement |
findElementByLinkText(java.lang.String linkText) |
WebElement |
findElementByPartialLinkText(java.lang.String linkText) |
WebElement |
findElementByTagName(java.lang.String name) |
WebElement |
findElementByXPath(java.lang.String xpathExpr) |
java.util.List<WebElement> |
findElements(By by)
Find all elements within the current context using the given mechanism.
|
java.util.List<WebElement> |
findElementsByCssSelector(java.lang.String using) |
java.util.List<WebElement> |
findElementsById(java.lang.String id) |
java.util.List<WebElement> |
findElementsByLinkText(java.lang.String linkText) |
java.util.List<WebElement> |
findElementsByPartialLinkText(java.lang.String linkText) |
java.util.List<WebElement> |
findElementsByTagName(java.lang.String name) |
java.util.List<WebElement> |
findElementsByXPath(java.lang.String xpathExpr) |
java.lang.String |
getAttribute(java.lang.String name)
Get the value of a the given attribute of the element.
|
Coordinates |
getCoordinates() |
java.lang.String |
getCssValue(java.lang.String propertyName)
Get the value of a given CSS property.
|
protected com.gargoylesoftware.htmlunit.html.DomElement |
getElement() |
java.util.List<WebElement> |
getElementsByTagName(java.lang.String tagName) |
Point |
getLocation()
Where on the page is the top left-hand corner of the rendered element?
|
protected HtmlUnitDriver |
getParent() |
Rectangle |
getRect() |
<X> X |
getScreenshotAs(OutputType<X> outputType)
Capture the screenshot and store it in the specified location.
|
Dimension |
getSize()
What is the width and height of the rendered element?
|
java.lang.String |
getTagName()
Get the tag name of this element.
|
java.lang.String |
getText()
Get the visible (i.e.
|
WebDriver |
getWrappedDriver() |
int |
hashCode() |
boolean |
isDisplayed()
Is this element displayed or not? This method avoids the problem of having to parse an
element's "style" attribute.
|
boolean |
isEnabled()
Is the element currently enabled or not? This will generally return true for everything but
disabled input elements.
|
boolean |
isSelected()
Determine whether or not this element is selected or not.
|
void |
sendKeys(java.lang.CharSequence... value)
Use this method to simulate typing into an element, which may set its value.
|
void |
submit()
If this current element is a form, or an element within a form, then this will be submitted to
the remote server.
|
java.lang.String |
toString() |
protected final HtmlUnitDriver parent
protected final com.gargoylesoftware.htmlunit.html.DomElement element
public HtmlUnitWebElement(HtmlUnitDriver parent, com.gargoylesoftware.htmlunit.html.DomElement element)
public void click()
WebElement
click
in interface WebElement
public void submit()
WebElement
submit
in interface WebElement
public void clear()
WebElement
WebElement.sendKeys(CharSequence...)
with the backspace key. To ensure
you get a change event, consider following with a call to WebElement.sendKeys(CharSequence...)
with the tab key.clear
in interface WebElement
public void sendKeys(java.lang.CharSequence... value)
WebElement
sendKeys
in interface WebElement
value
- character sequence to send to the elementpublic java.lang.String getTagName()
WebElement
"input"
for the element <input name="foo" />
.getTagName
in interface WebElement
public java.lang.String getAttribute(java.lang.String name)
WebElement
getAttribute
in interface WebElement
name
- The name of the attribute.public boolean isSelected()
WebElement
isSelected
in interface WebElement
public boolean isEnabled()
WebElement
isEnabled
in interface WebElement
public boolean isDisplayed()
WebElement
isDisplayed
in interface WebElement
public Point getLocation()
WebElement
getLocation
in interface WebElement
public Dimension getSize()
WebElement
getSize
in interface WebElement
public Rectangle getRect()
getRect
in interface WebElement
public java.lang.String getText()
WebElement
getText
in interface WebElement
protected HtmlUnitDriver getParent()
protected com.gargoylesoftware.htmlunit.html.DomElement getElement()
public java.util.List<WebElement> getElementsByTagName(java.lang.String tagName)
public WebElement findElement(By by)
WebElement
WebElement
using the given method. See the note in
WebElement.findElements(By)
about finding via XPath.
This method is affected by the 'implicit wait' times in force at the time of execution.
The findElement(..) invocation will return a matching row, or try again repeatedly until
the configured timeout is reached.
findElement should not be used to look for non-present elements, use WebElement.findElements(By)
and assert zero length response instead.findElement
in interface SearchContext
findElement
in interface WebElement
by
- The locating mechanismBy
,
WebDriver.Timeouts
public java.util.List<WebElement> findElements(By by)
WebElement
findElements
in interface SearchContext
findElements
in interface WebElement
by
- The locating mechanism to useWebElement
s, or an empty list if nothing matches.By
,
WebDriver.Timeouts
public WebElement findElementById(java.lang.String id)
findElementById
in interface FindsById
public java.util.List<WebElement> findElementsById(java.lang.String id)
findElementsById
in interface FindsById
public java.util.List<WebElement> findElementsByCssSelector(java.lang.String using)
findElementsByCssSelector
in interface FindsByCssSelector
public WebElement findElementByCssSelector(java.lang.String using)
findElementByCssSelector
in interface FindsByCssSelector
public WebElement findElementByXPath(java.lang.String xpathExpr)
findElementByXPath
in interface FindsByXPath
public java.util.List<WebElement> findElementsByXPath(java.lang.String xpathExpr)
findElementsByXPath
in interface FindsByXPath
public WebElement findElementByLinkText(java.lang.String linkText)
findElementByLinkText
in interface FindsByLinkText
public java.util.List<WebElement> findElementsByLinkText(java.lang.String linkText)
findElementsByLinkText
in interface FindsByLinkText
public WebElement findElementByPartialLinkText(java.lang.String linkText)
findElementByPartialLinkText
in interface FindsByLinkText
public java.util.List<WebElement> findElementsByPartialLinkText(java.lang.String linkText)
findElementsByPartialLinkText
in interface FindsByLinkText
public WebElement findElementByTagName(java.lang.String name)
findElementByTagName
in interface FindsByTagName
public java.util.List<WebElement> findElementsByTagName(java.lang.String name)
findElementsByTagName
in interface FindsByTagName
public java.lang.String toString()
toString
in class java.lang.Object
protected void assertElementNotStale()
public java.lang.String getCssValue(java.lang.String propertyName)
WebElement
getCssValue
in interface WebElement
propertyName
- the css property name of the elementpublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public WebDriver getWrappedDriver()
getWrappedDriver
in interface WrapsDriver
public Coordinates getCoordinates()
getCoordinates
in interface Locatable
public <X> X getScreenshotAs(OutputType<X> outputType) throws WebDriverException
TakesScreenshot
For WebDriver extending TakesScreenshot, this makes a best effort depending on the browser to return the following in order of preference:
For WebElement extending TakesScreenshot, this makes a best effort depending on the browser to return the following in order of preference: - The entire content of the HTML element - The visisble portion of the HTML element
getScreenshotAs
in interface TakesScreenshot
X
- Return type for getScreenshotAs.outputType
- target type, @see OutputTypeWebDriverException
- on failure.