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.HtmlElement |
element |
protected HtmlUnitDriver |
parent |
| Constructor and Description |
|---|
HtmlUnitWebElement(HtmlUnitDriver parent,
com.gargoylesoftware.htmlunit.html.HtmlElement 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.HtmlElement |
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() |
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 |
sendKeyDownEvent(java.lang.CharSequence modifierKey)
Deprecated.
Visibility will soon be reduced.
|
void |
sendKeys(java.lang.CharSequence... value)
Use this method to simulate typing into an element, which may set its value.
|
void |
sendKeyUpEvent(java.lang.CharSequence modifierKey)
Deprecated.
Visibility will soon be reduced.
|
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.HtmlElement element
public HtmlUnitWebElement(HtmlUnitDriver parent, com.gargoylesoftware.htmlunit.html.HtmlElement element)
public void click()
WebElementThere are some preconditions for an element to be clicked. The element must be visible and it must have a height and width greater then 0.
click in interface WebElementpublic void submit()
WebElementsubmit in interface WebElementpublic void clear()
WebElementWebElement.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 WebElementpublic void sendKeyDownEvent(java.lang.CharSequence modifierKey)
public void sendKeyUpEvent(java.lang.CharSequence modifierKey)
public void sendKeys(java.lang.CharSequence... value)
WebElementsendKeys in interface WebElementpublic java.lang.String getTagName()
WebElement"input" for the element <input name="foo" />.getTagName in interface WebElementpublic java.lang.String getAttribute(java.lang.String name)
WebElementgetAttribute in interface WebElementname - The name of the attribute.public boolean isSelected()
WebElementisSelected in interface WebElementpublic boolean isEnabled()
WebElementisEnabled in interface WebElementpublic boolean isDisplayed()
WebElementisDisplayed in interface WebElementpublic Point getLocation()
WebElementgetLocation in interface WebElementpublic Dimension getSize()
WebElementgetSize in interface WebElementpublic java.lang.String getText()
WebElementgetText in interface WebElementprotected HtmlUnitDriver getParent()
protected com.gargoylesoftware.htmlunit.html.HtmlElement getElement()
public java.util.List<WebElement> getElementsByTagName(java.lang.String tagName)
public WebElement findElement(By by)
WebElementWebElement 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 SearchContextfindElement in interface WebElementby - The locating mechanismBy,
WebDriver.Timeoutspublic java.util.List<WebElement> findElements(By by)
WebElementfindElements in interface SearchContextfindElements in interface WebElementby - The locating mechanism to useWebElements, or an empty list if nothing matches.By,
WebDriver.Timeoutspublic WebElement findElementById(java.lang.String id)
findElementById in interface FindsByIdpublic java.util.List<WebElement> findElementsById(java.lang.String id)
findElementsById in interface FindsByIdpublic java.util.List<WebElement> findElementsByCssSelector(java.lang.String using)
findElementsByCssSelector in interface FindsByCssSelectorpublic WebElement findElementByCssSelector(java.lang.String using)
findElementByCssSelector in interface FindsByCssSelectorpublic WebElement findElementByXPath(java.lang.String xpathExpr)
findElementByXPath in interface FindsByXPathpublic java.util.List<WebElement> findElementsByXPath(java.lang.String xpathExpr)
findElementsByXPath in interface FindsByXPathpublic WebElement findElementByLinkText(java.lang.String linkText)
findElementByLinkText in interface FindsByLinkTextpublic java.util.List<WebElement> findElementsByLinkText(java.lang.String linkText)
findElementsByLinkText in interface FindsByLinkTextpublic WebElement findElementByPartialLinkText(java.lang.String linkText)
findElementByPartialLinkText in interface FindsByLinkTextpublic java.util.List<WebElement> findElementsByPartialLinkText(java.lang.String linkText)
findElementsByPartialLinkText in interface FindsByLinkTextpublic WebElement findElementByTagName(java.lang.String name)
findElementByTagName in interface FindsByTagNamepublic java.util.List<WebElement> findElementsByTagName(java.lang.String name)
findElementsByTagName in interface FindsByTagNamepublic java.lang.String toString()
toString in class java.lang.Objectprotected void assertElementNotStale()
public java.lang.String getCssValue(java.lang.String propertyName)
WebElementgetCssValue in interface WebElementpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic WebDriver getWrappedDriver()
getWrappedDriver in interface WrapsDriverpublic Coordinates getCoordinates()
getCoordinates in interface Locatable