Finding returns element references
for the other element commands. Paths follow http://127.0.0.1:4445/{token};
see the overview for the reply format and the
errors.
Locator strategies#
using | Finds |
|---|---|
css selector | querySelector and querySelectorAll. |
xpath | The element nodes of document.evaluate, in document order, evaluated from the root. |
link text | a elements whose innerText, trimmed, equals value. |
partial link text | a elements whose innerText contains value. |
tag name | getElementsByTagName. |
Any other using answers 400 invalid argument (unknown locator strategy `...`),
and a selector or XPath the page cannot parse 400 invalid selector, with the
page’s own message.
Under the session’s implicit wait, finding looks again every 50 ms while nothing matches, until the wait is over (the default, 0, looks once).
Find element#
POST /session/{sessionId}/element
The first match in the current frame’s document (see Frames).
The current session’s id.
The locator strategy.
The selector, XPath, link text or tag name.
The element’s reference.
Errors
| Status | error | When |
|---|---|---|
| 400 | invalid argument | using or value is missing or not a string; an unknown strategy. |
| 400 | invalid selector | The page cannot parse the selector or the XPath. |
| 404 | no such element | Nothing matched before the implicit wait was over. |
| 404 | no such frame | The frame entered is gone or no longer same-origin. |
Find elements#
POST /session/{sessionId}/elements
Every match in the current frame’s document, in document order. Nothing matched is an empty array, not an error.
The current session’s id.
The locator strategy.
The selector, XPath, link text or tag name.
The elements’ references, possibly none.
Find element from element#
POST /session/{sessionId}/element/{elementId}/element
The first match inside an element. An XPath is evaluated with the element as
its context node, so .// looks inside it and // in the whole document.
The current session’s id.
The id of the element to search in.
The locator strategy.
The selector, XPath, link text or tag name.
The element’s reference.
Errors
As Find element, and 404 no such element or
404 stale element reference when elementId is unknown or gone.
Find elements from element#
POST /session/{sessionId}/element/{elementId}/elements
Every match inside an element; an empty array when none.
The current session’s id.
The id of the element to search in.
The locator strategy.
The selector, XPath, link text or tag name.
The elements’ references, possibly none.
Get active element#
GET /session/{sessionId}/element/active
The current frame’s focused element (document.activeElement), or its body
when nothing has the focus.
The current session’s id.
The element’s reference.