interface WebDriverElement implements WebDriverSearchContext (View source)

Interface for an HTML element in the WebDriver framework.

Methods

findElement(WebDriverBy $locator)

Find the first WebDriverElement within this element using the given mechanism.

findElements(WebDriverBy $locator)

Find all WebDriverElements within this element using the given mechanism.

clear()

If this element is a TEXTAREA or text INPUT element, this will clear the value.

click()

Click this element.

string|null
getAttribute(string $attribute_name)

Get the value of the given attribute of the element.

string
getCSSValue(string $css_property_name)

Get the value of a given CSS property.

getLocation()

Get the location of element relative to the top-left corner of the page.

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.

getSize()

Get the size of element.

string
getTagName()

Get the tag name of this element.

string
getText()

Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.

bool
isDisplayed()

Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.

bool
isEnabled()

Is the element currently enabled or not? This will generally return true for everything but disabled input elements.

bool
isSelected()

Determine whether or not this element is selected or not.

sendKeys(mixed $value)

Simulate typing into an element, which may set its value.

submit()

If this current element is a form, or an element within a form, then this will be submitted to the remote server.

string
getID()

Get the opaque ID of the element.

Details

WebDriverElement findElement(WebDriverBy $locator)

Find the first WebDriverElement within this element using the given mechanism.

Parameters

WebDriverBy $locator

Return Value

WebDriverElement

NoSuchElementException is thrown in HttpCommandExecutor if no element is found.

See also

WebDriverBy

WebDriverElement[] findElements(WebDriverBy $locator)

Find all WebDriverElements within this element using the given mechanism.

Parameters

WebDriverBy $locator

Return Value

WebDriverElement[]

A list of all WebDriverElements, or an empty array if nothing matches

See also

WebDriverBy

WebDriverElement clear()

If this element is a TEXTAREA or text INPUT element, this will clear the value.

Return Value

WebDriverElement

The current instance.

WebDriverElement click()

Click this element.

Return Value

WebDriverElement

The current instance.

string|null getAttribute(string $attribute_name)

Get the value of the given attribute of the element.

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

string $attribute_name

The name of the attribute.

Return Value

string|null

The value of the attribute.

string getCSSValue(string $css_property_name)

Get the value of a given CSS property.

Parameters

string $css_property_name

The name of the CSS property.

Return Value

string

The value of the CSS property.

WebDriverPoint getLocation()

Get the location of element relative to the top-left corner of the page.

Return Value

WebDriverPoint

The location of the element.

WebDriverPoint 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.

Return Value

WebDriverPoint

The location of the element.

WebDriverDimension getSize()

Get the size of element.

Return Value

WebDriverDimension

The dimension of the element.

string getTagName()

Get the tag name of this element.

Return Value

string

The tag name.

string getText()

Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.

Return Value

string

The visible innerText of this element.

bool isDisplayed()

Is this element displayed or not? This method avoids the problem of having to parse an element's "style" attribute.

Return Value

bool

bool isEnabled()

Is the element currently enabled or not? This will generally return true for everything but disabled input elements.

Return Value

bool

bool isSelected()

Determine whether or not this element is selected or not.

Return Value

bool

WebDriverElement sendKeys(mixed $value)

Simulate typing into an element, which may set its value.

Parameters

mixed $value

The data to be typed.

Return Value

WebDriverElement

The current instance.

WebDriverElement submit()

If this current element is a form, or an element within a form, then this will be submitted to the remote server.

Return Value

WebDriverElement

The current instance.

string getID()

Get the opaque ID of the element.

Return Value

string

The opaque ID.