class RemoteWebElement implements WebDriverElement, WebDriverLocatable (View source)

Represents an HTML element.

Properties

protected RemoteExecuteMethod $executor
protected string $id
protected FileDetector $fileDetector
protected bool $isW3cCompliant

Methods

__construct(RemoteExecuteMethod $executor, string $id, bool $isW3cCompliant = false)

No description

clear()

Clear content editable or resettable element

click()

Click this element.

findElement(WebDriverBy $by)

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

findElements(WebDriverBy $by)

Find all WebDriverElements within this element using the given mechanism.

string|null
getAttribute(string $attribute_name)

Get the value of the given attribute of the element.

mixed|null
getDomProperty(string $propertyName)

Gets the value of a IDL JavaScript property of this element (for example innerHTML, tagName etc.).

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 (lowercase) 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 this element is selected or not.

sendKeys(mixed $value)

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

setFileDetector(FileDetector $detector)

Set the fileDetector in order to let the RemoteWebElement to know that you are going to upload a file.

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.

string
takeElementScreenshot(string $save_as = null)

Take a screenshot of a specific element.

bool
equals(WebDriverElement $other)

Test if two elements IDs refer to the same DOM element.

clickChildElement(ElementNotInteractableException $originalException)

Attempt to click on a child level element.

newElement(string $id)

Return the WebDriverElement with $id

string
upload(string $local_file)

Upload a local file to the server

string
createTemporaryZipArchive(string $fileToZip)

No description

Details

__construct(RemoteExecuteMethod $executor, string $id, bool $isW3cCompliant = false)

No description

Parameters

RemoteExecuteMethod $executor
string $id
bool $isW3cCompliant

WebDriverElement clear()

Clear content editable or resettable element

Return Value

WebDriverElement

The current instance.

WebDriverElement click()

Click this element.

Return Value

WebDriverElement

The current instance.

WebDriverElement findElement(WebDriverBy $by)

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

When using xpath be aware that webdriver follows standard conventions: a search prefixed with "//" will search the entire document from the root, not just the children (relative context) of this current node. Use ".//" to limit your search to the children of this element.

Parameters

WebDriverBy $by

Return Value

WebDriverElement

NoSuchElementException is thrown in HttpCommandExecutor if no element is found.

See also

WebDriverBy

WebDriverElement[] findElements(WebDriverBy $by)

Find all WebDriverElements within this element using the given mechanism.

When using xpath be aware that webdriver follows standard conventions: a search prefixed with "//" will search the entire document from the root, not just the children (relative context) of this current node. Use ".//" to limit your search to the children of this element.

Parameters

WebDriverBy $by

Return Value

WebDriverElement[]

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

See also

WebDriverBy

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.

mixed|null getDomProperty(string $propertyName)

Gets the value of a IDL JavaScript property of this element (for example innerHTML, tagName etc.).

Parameters

string $propertyName

Return Value

mixed|null

The property's current value or null if the value is not set or the property does not exist.

See also

https://developer.mozilla.org/en-US/docs/Glossary/IDL
https://developer.mozilla.org/en-US/docs/Web/API/Element#properties

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.

WebDriverCoordinates getCoordinates()

No description

Return Value

WebDriverCoordinates

WebDriverDimension getSize()

Get the size of element.

Return Value

WebDriverDimension

The dimension of the element.

string getTagName()

Get the (lowercase) 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 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.

RemoteWebElement setFileDetector(FileDetector $detector)

Set the fileDetector in order to let the RemoteWebElement to know that you are going to upload a file.

Basically, if you want WebDriver trying to send a file, set the fileDetector to be LocalFileDetector. Otherwise, keep it UselessFileDetector.

eg. $element->setFileDetector(new LocalFileDetector);

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.

string takeElementScreenshot(string $save_as = null)

Take a screenshot of a specific element.

Parameters

string $save_as

The path of the screenshot to be saved.

Return Value

string

The screenshot in PNG format.

bool equals(WebDriverElement $other)

Test if two elements IDs refer to the same DOM element.

Parameters

WebDriverElement $other

Return Value

bool

protected clickChildElement(ElementNotInteractableException $originalException)

Attempt to click on a child level element.

This provides a workaround for geckodriver bug 653 whereby a link whose first element is a block-level element throws an ElementNotInteractableException could not scroll into view exception.

The workaround provided here attempts to click on a child node of the element. In case the first child is hidden, other elements are processed until we run out of elements.

Parameters

ElementNotInteractableException $originalException

The exception to throw if unable to click on any child

See also

https://github.com/mozilla/geckodriver/issues/653
https://bugzilla.mozilla.org/show_bug.cgi?id=1374283

protected RemoteWebElement newElement(string $id)

Return the WebDriverElement with $id

Parameters

string $id

Return Value

RemoteWebElement

protected string upload(string $local_file)

Upload a local file to the server

Parameters

string $local_file

Return Value

string

The remote path of the file.

Exceptions

WebDriverException

protected string createTemporaryZipArchive(string $fileToZip)

No description

Parameters

string $fileToZip

Return Value

string