public interface WebElement extends SearchContext
StaleElementReferenceException
is thrown, and all
future calls to this instance will fail.Modifier and Type | Method and Description |
---|---|
void |
clear()
If this element is a text entry element, this will clear the value.
|
void |
click()
Click this element.
|
WebElement |
findElement(By by)
Find the first
WebElement using the given method. |
List<WebElement> |
findElements(By by)
Find all elements within the current context using the given mechanism.
|
String |
getAttribute(String name)
Get the value of a the given attribute of the element.
|
String |
getCssValue(String propertyName)
Get the value of a given CSS property.
|
Point |
getLocation()
Where on the page is the top left-hand corner of the rendered element?
|
Dimension |
getSize()
What is the width and height of the rendered element?
|
String |
getTagName()
Get the tag name of this element.
|
String |
getText()
Get the visible (i.e.
|
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(CharSequence... keysToSend)
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.
|
void click()
StaleElementReferenceException
- If the element no longer exists as initially definedvoid submit()
NoSuchElementException
- If the given element is not within a formvoid sendKeys(CharSequence... keysToSend)
void clear()
sendKeys(CharSequence...)
with the backspace key. To ensure
you get a change event, consider following with a call to sendKeys(CharSequence...)
with the tab key.String getTagName()
"input"
for the element <input name="foo" />
.String getAttribute(String name)
name
- The name of the attribute.boolean isSelected()
boolean isEnabled()
String getText()
List<WebElement> findElements(By by)
findElements
in interface SearchContext
by
- The locating mechanism to useWebElement
s, or an empty list if nothing matches.By
,
WebDriver.Timeouts
WebElement findElement(By by)
WebElement
using the given method. See the note in
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 findElements(By)
and assert zero length response instead.findElement
in interface SearchContext
by
- The locating mechanismNoSuchElementException
- If no matching elements are foundBy
,
WebDriver.Timeouts
boolean isDisplayed()
Point getLocation()
Dimension getSize()
String getCssValue(String propertyName)
Copyright © 2014. All rights reserved.