RemoteWebElement
in package
implements
WebDriverElement, WebDriverLocatable
Represents an HTML element.
Table of Contents
Interfaces
- WebDriverElement
- Interface for an HTML element in the WebDriver framework.
- WebDriverLocatable
- Interface representing basic mouse operations.
Properties
- $executor : RemoteExecuteMethod
- $fileDetector : FileDetector
- $id : string
- $isW3cCompliant : bool
Methods
- __construct() : mixed
- clear() : RemoteWebElement
- Clear content editable or resettable element
- click() : RemoteWebElement
- Click this element.
- equals() : bool
- Test if two elements IDs refer to the same DOM element.
- findElement() : RemoteWebElement
- Find the first WebDriverElement within this element using the given mechanism.
- findElements() : array<string|int, RemoteWebElement>
- Find all WebDriverElements within this element using the given mechanism.
- getAttribute() : string|true|null
- Get the value of the given attribute of the element.
- getCoordinates() : WebDriverCoordinates
- getCSSValue() : string
- Get the value of a given CSS property.
- getDomProperty() : mixed|null
- Gets the value of a IDL JavaScript property of this element (for example `innerHTML`, `tagName` etc.).
- 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.
- getShadowRoot() : ShadowRoot
- Get representation of an element's shadow root for accessing the shadow DOM of a web component.
- getSize() : WebDriverDimension
- Get the size of element.
- getTagName() : string
- Get the (lowercase) 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 this element is selected or not.
- sendKeys() : RemoteWebElement
- Simulate typing into an element, which may set its value.
- setFileDetector() : RemoteWebElement
- Set the fileDetector in order to let the RemoteWebElement to know that you are going to upload a file.
- submit() : RemoteWebElement
- If this current element is a form, or an element within a form, then this will be submitted to the remote server.
- takeElementScreenshot() : string
- Take a screenshot of a specific element.
- clickChildElement() : mixed
- Attempt to click on a child level element.
- createTemporaryZipArchive() : string
- newElement() : static
- Return the WebDriverElement with $id
- upload() : string
- Upload a local file to the server
Properties
$executor
protected
RemoteExecuteMethod
$executor
$fileDetector
protected
FileDetector
$fileDetector
$id
protected
string
$id
$isW3cCompliant
protected
bool
$isW3cCompliant
Methods
__construct()
public
__construct(RemoteExecuteMethod $executor, string $id[, bool $isW3cCompliant = false ]) : mixed
Parameters
- $executor : RemoteExecuteMethod
- $id : string
- $isW3cCompliant : bool = false
clear()
Clear content editable or resettable element
public
clear() : RemoteWebElement
Return values
RemoteWebElement —The current instance.
click()
Click this element.
public
click() : RemoteWebElement
Return values
RemoteWebElement —The current instance.
equals()
Test if two elements IDs refer to the same DOM element.
public
equals(WebDriverElement $other) : bool
Parameters
- $other : WebDriverElement
Return values
boolfindElement()
Find the first WebDriverElement within this element using the given mechanism.
public
findElement(WebDriverBy $by) : RemoteWebElement
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
- $by : WebDriverBy
Tags
Return values
RemoteWebElement —NoSuchElementException is thrown in HttpCommandExecutor if no element is found.
findElements()
Find all WebDriverElements within this element using the given mechanism.
public
findElements(WebDriverBy $by) : array<string|int, RemoteWebElement>
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
- $by : WebDriverBy
Tags
Return values
array<string|int, RemoteWebElement> —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|true|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|true|null —The value of the attribute. If this is boolean attribute, return true if the element has it, otherwise return null.
getCoordinates()
public
getCoordinates() : WebDriverCoordinates
Return values
WebDriverCoordinatesgetCSSValue()
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.
getDomProperty()
Gets the value of a IDL JavaScript property of this element (for example `innerHTML`, `tagName` etc.).
public
getDomProperty(string $propertyName) : mixed|null
Parameters
- $propertyName : string
Tags
Return values
mixed|null —The property's current value or null if the value is not set or the property does not exist.
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.
getShadowRoot()
Get representation of an element's shadow root for accessing the shadow DOM of a web component.
public
getShadowRoot() : ShadowRoot
Return values
ShadowRootgetSize()
Get the size of element.
public
getSize() : WebDriverDimension
Return values
WebDriverDimension —The dimension of the element.
getTagName()
Get the (lowercase) 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 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) : RemoteWebElement
Parameters
- $value : mixed
-
The data to be typed.
Return values
RemoteWebElement —The current instance.
setFileDetector()
Set the fileDetector in order to let the RemoteWebElement to know that you are going to upload a file.
public
setFileDetector(FileDetector $detector) : RemoteWebElement
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);
Parameters
- $detector : FileDetector
Tags
Return values
RemoteWebElementsubmit()
If this current element is a form, or an element within a form, then this will be submitted to the remote server.
public
submit() : RemoteWebElement
Return values
RemoteWebElement —The current instance.
takeElementScreenshot()
Take a screenshot of a specific element.
public
takeElementScreenshot([string $save_as = null ]) : string
Parameters
- $save_as : string = null
-
The path of the screenshot to be saved.
Return values
string —The screenshot in PNG format.
clickChildElement()
Attempt to click on a child level element.
protected
clickChildElement(ElementNotInteractableException $originalException) : mixed
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
- $originalException : ElementNotInteractableException
-
The exception to throw if unable to click on any child
Tags
createTemporaryZipArchive()
protected
createTemporaryZipArchive(string $fileToZip) : string
Parameters
- $fileToZip : string
Return values
stringnewElement()
Return the WebDriverElement with $id
protected
newElement(string $id) : static
Parameters
- $id : string
Return values
staticupload()
Upload a local file to the server
protected
upload(string $local_file) : string
Parameters
- $local_file : string
Tags
Return values
string —The remote path of the file.