WebDriverElement
extends
WebDriverSearchContext
in
Interface for an HTML element in the WebDriver framework.
Table of Contents
Methods
- clear() : WebDriverElement
- If this element is a TEXTAREA or text INPUT element, this will clear the value.
- click() : WebDriverElement
- Click this element.
- findElement() : WebDriverElement
- Find the first WebDriverElement within this element using the given mechanism.
- findElements() : array<string|int, WebDriverElement>
- Find all WebDriverElements within this element using the given mechanism.
- getAttribute() : string|null
- Get the value of the given attribute of the element.
- getCSSValue() : string
- Get the value of a given CSS property.
- getID() : string
- Get the opaque ID of the element.
- getLocation() : WebDriverPoint
- Get the location of element relative to the top-left corner of the page.
- getLocationOnScreenOnceScrolledIntoView() : WebDriverPoint
- Try scrolling the element into the view port and return the location of element relative to the top-left corner of the page afterwards.
- getSize() : WebDriverDimension
- Get the size of element.
- getTagName() : string
- Get the tag name of this element.
- getText() : string
- Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.
- isDisplayed() : bool
- Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.
- isEnabled() : bool
- Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
- isSelected() : bool
- Determine whether or not this element is selected or not.
- sendKeys() : WebDriverElement
- Simulate typing into an element, which may set its value.
- submit() : WebDriverElement
- If this current element is a form, or an element within a form, then this will be submitted to the remote server.
Methods
clear()
If this element is a TEXTAREA or text INPUT element, this will clear the value.
public
clear() : WebDriverElement
Return values
WebDriverElement —The current instance.
click()
Click this element.
public
click() : WebDriverElement
Return values
WebDriverElement —The current instance.
findElement()
Find the first WebDriverElement within this element using the given mechanism.
public
findElement(WebDriverBy $locator) : WebDriverElement
Parameters
- $locator : WebDriverBy
Tags
Return values
WebDriverElementfindElements()
Find all WebDriverElements within this element using the given mechanism.
public
findElements(WebDriverBy $locator) : array<string|int, WebDriverElement>
Parameters
- $locator : WebDriverBy
Tags
Return values
array<string|int, WebDriverElement> —A list of all WebDriverElements, or an empty array if nothing matches
getAttribute()
Get the value of the given attribute of the element.
public
getAttribute(string $attribute_name) : string|null
Attribute is meant what is declared in the HTML markup of the element.
To read a value of a IDL "JavaScript" property (like innerHTML
), use getDomProperty()
method.
Parameters
- $attribute_name : string
-
The name of the attribute.
Return values
string|null —The value of the attribute.
getCSSValue()
Get the value of a given CSS property.
public
getCSSValue(string $css_property_name) : string
Parameters
- $css_property_name : string
-
The name of the CSS property.
Return values
string —The value of the CSS property.
getID()
Get the opaque ID of the element.
public
getID() : string
Return values
string —The opaque ID.
getLocation()
Get the location of element relative to the top-left corner of the page.
public
getLocation() : WebDriverPoint
Return values
WebDriverPoint —The location of the element.
getLocationOnScreenOnceScrolledIntoView()
Try scrolling the element into the view port and return the location of element relative to the top-left corner of the page afterwards.
public
getLocationOnScreenOnceScrolledIntoView() : WebDriverPoint
Return values
WebDriverPoint —The location of the element.
getSize()
Get the size of element.
public
getSize() : WebDriverDimension
Return values
WebDriverDimension —The dimension of the element.
getTagName()
Get the tag name of this element.
public
getTagName() : string
Return values
string —The tag name.
getText()
Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.
public
getText() : string
Return values
string —The visible innerText of this element.
isDisplayed()
Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.
public
isDisplayed() : bool
Return values
boolisEnabled()
Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
public
isEnabled() : bool
Return values
boolisSelected()
Determine whether or not this element is selected or not.
public
isSelected() : bool
Return values
boolsendKeys()
Simulate typing into an element, which may set its value.
public
sendKeys(mixed $value) : WebDriverElement
Parameters
- $value : mixed
-
The data to be typed.
Return values
WebDriverElement —The current instance.
submit()
If this current element is a form, or an element within a form, then this will be submitted to the remote server.
public
submit() : WebDriverElement
Return values
WebDriverElement —The current instance.