WebDriver

W3C Editor's Draft

This version:
https://w3c.github.io/webdriver/
Latest published version:
https://www.w3.org/TR/webdriver/
Latest editor's draft:
https://w3c.github.io/webdriver/
Editors:
Simon Stewart ( Apple )
David Burns ( BrowserStack )
Participate:
GitHub w3c/webdriver
File an issue
Commit history
Pull requests
Channel
#webdriver on irc.w3.org

Abstract

WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.

Provided is a set of interfaces to discover and manipulate DOM elements in web documents and to control the behavior of a user agent. It is primarily intended to allow web authors to write tests that automate a user agent from a separate controlling process, but may also be used in such a way as to allow in-browser scripts to control a — possibly separate — browser.

Status of This Document

This is a preview

Do not attempt to implement this version of the specification. Do not reference this version as authoritative in any way. Instead, see https://w3c.github.io/webdriver/ for the Editor's draft.

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at https://www.w3.org/TR/.

This document was published by the Browser Testing and Tools Working Group as an Editor's Draft.

GitHub Issues are preferred for discussion of this specification.

Publication as an Editor's Draft does not imply endorsement by the W3C Membership.

This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

This document was produced by a group operating under the W3C Patent Policy . W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy .

This document is governed by the 15 September 2020 W3C Process Document .

1. Design

This section is non-normative.

The WebDriver standard attempts to follow a number of design goals:

1.1 Compatibility

This specification is derived from the popular Selenium WebDriver browser automation framework. Selenium is a long-lived project, and due to its age and breadth of use it has a wide range of expected functionality. This specification uses these expectations to inform its design. Where improvements or clarifications have been made, they have been made with care to allow existing users of Selenium WebDriver to avoid unexpected breakages.

1.2 Simplicity

The largest intended group of users of this specification are software developers and testers writing automated tests and other tooling, such as monitoring or load testing, that relies on automating a browser. As such, care has been taken to provide commands that simplify common tasks such as typing into and clicking elements.

1.3 Extensions

WebDriver provides a mechanism for others to define extensions to the protocol for the purposes of automating functionality that cannot be implemented entirely in ECMAScript . This allows other web standards to support the automation of new platform features. It also allows vendors to expose functionality that is specific to their browser.

2. Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. Algorithms in this document are typically written with readability, rather than performance, in mind.

3. Terminology

In equations, all numbers are integers, addition is represented by “+”, subtraction by “−”, division by “÷”, and bitwise OR by “|”. The characters “(” and “)” are used to provide logical grouping in these contexts.

The mathematical function min ( value , value [, value ]) returns the smallest item of two or more values. Conversely, the function max ( value , value [, value ]) returns the largest item of two or more values.

The mathematical function floor ( value ) produces the largest integer, closest to positive infinity, that is not larger than value .

A Universally Unique Identifier (UUID) is a 128 bits long URN that requires no central registration process. Generating a UUID means Creating a UUID From Truly Random or Pseudo-Random Numbers , and converting it to the string representation. [ RFC4122 ]

The Unix Epoch is a value that approximates the number of seconds that have elapsed since the Epoch, as described by The Open Group Base Specifications Issue 7 section 4.15 (IEEE Std 1003.1).

An integer is a Number that is unchanged under the ToInteger operation.

The initial value of an ECMAScript property is the value defined by the platform for that property, i.e. the value it would have in the absence of any shadowing by content script.

The browser chrome is a non-normative term to refer to the representation through which the user interacts with the user agent itself, as distinct from the accessed web content. Examples of browser chrome elements include, but are not limited to, toolbars (such as the bookmark toolbar), menus (such as the file or context menu), buttons (such as the back and forward buttons), door hangers (such as security and certificate indicators), and decorations (such as operating system widget borders).

4. Interface

The webdriver-active flag is set to true when the user agent is under remote control. It is initially false.

WebIDLinterface mixin NavigatorAutomationInformation {
  readonly attribute boolean webdriver;
};

Navigator

includes


NavigatorAutomationInformation


;


Note

The NavigatorAutomationInformation interface should not be exposed on WorkerNavigator .

webdriver

Returns true if webdriver-active flag is set, false otherwise.

It is acknowledged that this is complementary to the Evil Bit [ RFC3514 ].

5. Nodes

The WebDriver protocol consists of communication between:

Local end

The local end represents the client side of the protocol, which is usually in the form of language-specific libraries providing an API on top of the WebDriver protocol . This specification does not place any restrictions on the details of those libraries above the level of the wire protocol.

Remote end
The remote end hosts the server side of the protocol . Defining the behavior of a remote end in response to the WebDriver protocol forms the largest part of this specification.

For remote ends the standard defines two broad conformance classes, known as node types :

Intermediary node
Intermediary nodes are those that act as proxies, implementing both the local end and remote end of the protocol . However they are not expected to implement remote end steps directly. All nodes between a specific intermediary node and a local end are said to be downstream of that node. Conversely, any nodes between a specific intermediary node and an endpoint node are said to be upstream .
Endpoint node
An endpoint node is the final remote end in a chain of nodes that is not an intermediary node . The endpoint node is implemented by a user agent or a similar program.

All remote end node types must be black-box indistinguishable from a remote end , from the point of view of local end , and so are bound by the requirements on a remote end in terms of the wire protocol.

The readiness state of a remote end indicates whether it is free to accept new connections. It must be false if the maximum active sessions implementation is equal to the length of an endpoint node and the list of active HTTP sessions , is not empty, or otherwise if the node is an intermediary node remote end and is known to be in a state in which attempting to create new sessions would fail. In all other cases it must be true.

If the intermediary node is a multiplexer that manages multiple endpoint nodes , this might indicate its ability to purvey more sessions , for example if it has hit its maximum capacity.

6. Protocol

WebDriver remote ends must provide an HTTP compliant wire protocol where the endpoints map to different commands .

As this standard only defines the remote end protocol, it puts no demands to how local ends should be implemented. Local ends are only expected to be compatible to the extent that they can speak the remote end ’s protocol; no requirements are made upon their exposed user-facing API.

6.1 Algorithms

Various parts of this specification are written in terms of step-by-step algorithms. The details of these algorithms do not have any normative significance; implementations are free to adopt any implementation strategy that produces equivalent output to the specification. In particular, algorithms in this document are optimised for readability rather than performance.

Where algorithms that return values are fallible, they are written in terms of returning either success or error . A success value has an associated data field which encapsulates the value returned, whereas an error response has an associated error code .

When calling a fallible algorithm, the construct “Let result be the result of trying to call algorithm ” is equivalent to

  1. Let temp be the result of calling algorithm .

  2. If temp is an error return temp , otherwise let result be temp ’s data field.

The result of getting a property with argument named name from object is defined as being the same as the result of calling Object . object . [[GetOwnProperty]] ( name ).

The result of getting a property with default with arguments named name and with default is defined as being the same as the result of calling Object . from is defined as being the same as the result of calling object . [[GetOwnProperty]] ( name ) if that results in a value other than ) if that results in a value other than undefined and and default otherwise. otherwise.

Setting a property with arguments Setting a property with arguments name and and value is defined as being the same as calling is defined as being the same as calling Object . [[Put]] ( name , , value ). The result of JSON serialization with ).

The result of JSON serialization with object of type JSON of type JSON Object is defined as the result of calling is defined as the result of calling JSON. [[Stringify]] ( object ). The result of JSON deserialization with ).

The result of JSON deserialization with text is defined as the result of calling is defined as the result of calling JSON. [[Parse]] ( text ). ).

6.2 6.2 Commands The WebDriver protocol is organised into

The WebDriver protocol is organised into commands . Each HTTP request with a method and template defined in this specification represents a single command , and therefore each . Each HTTP request with a method and template defined in this specification represents a single command produces a single HTTP response . In response to a , and therefore each command produces a single HTTP response .

In response to a command , a remote end will run a series of actions known as remote end steps . These provide the sequences of actions that a remote end takes when it receives a particular , a remote end will run a series of actions known as remote end steps . These provide the sequences of actions that a remote end takes when it receives a particular command . .

6.3 Processing model 6.3 Processing model The remote end is an HTTP server reading requests from the client and writing responses, typically over a TCP socket. For the purposes of this specification we model the data transmission between a particular local end and remote end with a

The remote end is an HTTP server reading requests from the client and writing responses, typically over a TCP socket. For the purposes of this specification we model the data transmission between a particular local end and remote end with a connection to which the remote end may write bytes and read bytes . However the exact details of how this to which the remote end may write bytes and read bytes . However the exact details of how this connection works and how it is established are out of scope. After such a works and how it is established are out of scope.

After a connection has been established, a remote end must run the following steps: is established, the remote end must run the following steps:

  1. While the connection is not closed:

    1. Read bytes from the Read bytes from the connection until a complete HTTP request can be constructed from the data. Let until a complete HTTP request can be constructed from the data. Let request be a be a request constructed from the received data, according to the requirements of [ constructed from the received data, according to the requirements of [ RFC7230 ]. If it is not possible to construct a complete HTTP request , the remote end must either close the ]. If it is not possible to construct a complete HTTP request , the remote end must either close the connection , return an HTTP response with status code 500, or return an error with error code unknown , return an HTTP response with status code 500, or return an error . with error code unknown error .

    2. Let request match be the result of the algorithm to match a request with Let request match be the result of the algorithm to match a request with request ’s ’s method and and URL as arguments. as arguments.

    3. If request match is of type error , send an error with request match ’s If request match is of type error code and jump to step 1. Otherwise, let command and command parameters be request match ’s data. Let url variables , send an error with request match be a url variables dictionary mapping the ’s error code and continue.

      Otherwise, let command parameters and URL variables be request match to their corresponding values. ’s data.

    4. If Let session id is among the variables defined by command parameters : be null.

    5. If URL variables has an item named session id:

      Note

      This condition is intended to exclude the New Session and This condition is intended to exclude the New Session and Status commands and any extension commands which do not operate on a particular and any extension commands which do not operate on a particular session . .

      1. Let session id Let session id be URL variables be the corresponding variable from command parameters . 's session id.

      2. Let the current session be the session with ID session id in the list of active sessions , or null if there is no such matching session . For each active session in the list of active sessions :

        1. If the current session is null send an error with error code invalid If active session 's session ID is equal to session id , then let session id , then jump to step 1 in this overall algorithm. be active session , and break.

      3. If the current If the session is not is null : Enqueue request in the current session ’s request queue . send an error with error code invalid session id , then continue.

    6. Wait until the first element in the current session ’s request queue Enqueue a task on remote end is request : Dequeue request from the current 's request queue to run the following steps:

      1. If session ’s request queue . is no longer in the list of active sessions , then return.
      2. If the list of active sessions no longer contains the current session , set the current session to Let parameters be null . .

      3. If If request ’s ’s method is POST: is POST:

        1. Let parse result be the result of parsing as JSON with Let parse result be the result of parsing as JSON with request ’s ’s body as the argument. If this process throws an exception, return an error with as the argument. If this process throws an exception, return an error code invalid argument and jump back to step 1 in this overall algorithm. with error code invalid argument and jump back to step 1 in this overall algorithm.

        2. If parse result is not an If parse result is not an Object , send an error with error code invalid argument and jump back to step 1 in this overall algorithm. Otherwise, let parameters be parse result . Otherwise, let , send an error with error code invalid argument and jump back to step 1 in this overall algorithm.

          Otherwise, let parameters be null . be parse result .

      4. Let navigate result be the result of wait for navigation to complete .

      5. Wait for navigation to complete . If this returns an

        If navigate result is an error return its value and jump to step 1 in this overall algorithm, otherwise continue. , send an error with error code equal to navigate result ’s error code and return.

      6. Let response result be the return value obtained by running the remote end steps for Let response result be the return value obtained by running the remote end steps for command with an argument named url variables whose value is url variables and an additional argument named parameters whose value is with session , URL variables , and parameters . .

      7. If response result is an error , send an error with If response result is an error code equal to response result , send an error with error code equal to response result ’s error code and jump back to step 1 in this overall algorithm. ’s error code and return.

      8. Otherwise, if response result is a Assert: response result is a success , let response data be response result .

      9. Let response data be response result ’s data. ’s data.

      10. Send a response with status 200 and response data . Jump to step 1. When required to send an error , with error code and an optional error data dictionary, a remote end must run the following steps: Send a response with status 200 and response data .

When required to send an error , with error code and an optional error data dictionary, a remote end must run the following steps:

  1. Let Let status and and name be the error response data for error code . be the error response data for error code .

  2. Let Let message be an implementation-defined string containing a human-readable description of the reason for the error. be an implementation-defined string containing a human-readable description of the reason for the error.

  3. Let Let stacktrace be an implementation-defined string containing a stack trace report of the active stack frames at the time when the error occurred. Let be an implementation-defined string containing a stack trace report of the active stack frames at the time when the error occurred.

    Let body be a new JSON be a new JSON Object initialized with the following properties: initialized with the following properties:

    " error " "
    name
    " message " "
    message
    " stacktrace " "
    stacktrace
  4. If the error data dictionary contains any entries, set the " If the error data dictionary contains any entries, set the " data " field on " field on body to a new JSON to a new JSON Object populated with the dictionary. populated with the dictionary.

  5. Send a response with Send a response with status and and body as arguments. When required to send a response , with arguments as arguments.

When required to send a response , with arguments status and and data , a remote end must run the following steps: , a remote end must run the following steps:

  1. Let Let response be a new be a new response . .

  2. Set Set response ’s HTTP status to status , and status message to the string corresponding to the description of ’s HTTP status to status in the , and status message to the string corresponding to the description of status code registry . in the status code registry .

  3. Set the the response ’s ’s header with with name and and value with the following values: with the following values:

    Content-Type
    " application/json; charset=utf-8 application/json; charset=utf-8 " "
    Cache-Control
    " no-cache " "
  4. Let Let response ’s ’s body be the UTF-8 encoded JSON serialization of a JSON be the UTF-8 encoded JSON serialization of a JSON Object with a key " with a key " value " set to " set to data . .

  5. Let response bytes be the byte sequence resulting from serializing Let response bytes be the byte sequence resulting from serializing response according to the rules in [ according to the rules in [ RFC7230 ]. ].

  6. Write response bytes to the response bytes to the connection . A url variable dictionary is defined as the mapping of a command ’s URI template variable names to their corresponding values. .

6.4 Routing requests 6.4 Routing requests

Request routing is the process of going from a HTTP request to the series of steps needed to implement the Request routing is the process of going from a HTTP request to the series of steps needed to implement the command represented by that request. A remote end has an associated URL prefix , which is used as a prefix on all WebDriver-defined URLs on that remote end . This must either be represented by that request.

A remote end has an associated URL prefix , which is used as a prefix on all WebDriver-defined URLs on that remote end . This must either be undefined or a path-absolute URL . or a path-absolute URL .

In order to match a request given a method and and URL , the following steps must be taken: , the following steps must be taken:

  1. Let endpoints be a list containing each row in the table of Let endpoints . be a list containing each row in the table of endpoints .

  2. Remove each entry from Remove each entry from endpoints for which the concatenation of the URL prefix and the entry’s URI template does not match for which the concatenation of the URL prefix and the entry’s URI template does not have a valid expansion equal to to URL ’s ’s path . .

  3. If there are no entries in If there are no entries in endpoints , return error with , return error code unknown command . with error code unknown command .

  4. Remove each entry in Remove each entry in endpoints for which the for which the method column is not equal to column is not equal to method . .

  5. If there are no entries in If there are no entries in endpoints , return error with , return error code unknown method . with error code unknown method .

  6. There is now exactly one entry in There is now exactly one entry in endpoints ; let ; let entry be this entry. be this entry.

  7. Let parameters be the result of extracting the variables from URL using Let URI template be the concatenation of URL prefix with entry ’s URI template . 's URI template .

  8. Let Let command be be entry ’s ’s command . .

  9. Return Let URL variables be a struct with one item for each variable defined in URI template , with the item name equal to the template variable name, and the item value being the variable value required to expand the URI template to match URL 's path .

  10. Return success with data with data command and parameters . and URL variables .

6.5 6.5 Endpoints The following table of endpoints lists the

The following table of endpoints lists the method and URI template for each endpoint node and URI template for each endpoint node command . Extension commands are implicitly appended to this table. . Extension commands are implicitly appended to this table.

Method URI Template URI Template Command
POST /session New Session New Session
DELETE /session/{ session id session id } Delete Session Delete Session
GET /status Status
GET /session/{ session id session id }/timeouts Get Timeouts Get Timeouts
POST /session/{ session id session id }/timeouts Set Timeouts Set Timeouts
POST /session/{ session id session id }/url Navigate To Navigate To
GET /session/{ session id session id }/url Get Current URL Get Current URL
POST /session/{ session id session id }/back Back
POST /session/{ session id session id }/forward Forward
POST /session/{ session id session id }/refresh Refresh
GET /session/{ session id session id }/title Get Title Get Title
GET /session/{ session id session id }/window Get Window Handle Get Window Handle
DELETE /session/{ session id session id }/window Close Window Close Window
POST /session/{ session id session id }/window Switch To Window Switch To Window
GET /session/{ session id session id }/window/handles Get Window Handles Get Window Handles
POST /session/{ session id session id }/window/new New Window New Window
POST /session/{ session id session id }/frame Switch To Frame Switch To Frame
POST /session/{ session id session id }/frame/parent Switch To Parent Frame Switch To Parent Frame
GET /session/{ session id session id }/window/rect Get Window Rect Get Window Rect
POST /session/{ session id session id }/window/rect Set Window Rect Set Window Rect
POST /session/{ session id session id }/window/maximize Maximize Window Maximize Window
POST /session/{ session id session id }/window/minimize Minimize Window Minimize Window
POST /session/{ session id session id }/window/fullscreen Fullscreen Window Fullscreen Window
GET /session/{ session id session id }/element/active Get Active Element Get Active Element
GET /session/{ session id session id }/element/{ element id element id }/shadow Get Element Shadow Root Get Element Shadow Root
POST /session/{ session id session id }/element Find Element Find Element
POST /session/{ session id session id }/elements Find Elements Find Elements
POST /session/{ session id session id }/element/{element id}/element }/element/{element id}/element Find Element From Element Find Element From Element
POST /session/{ session id session id }/element/{element id}/elements }/element/{element id}/elements Find Elements From Element Find Elements From Element
POST /session/{ session id session id }/shadow/ {shadow id} {shadow id} /element Find Element From Shadow Root Find Element From Shadow Root
POST /session/{ session id session id }/shadow/ {shadow id} {shadow id} /elements Find Elements From Shadow Root Find Elements From Shadow Root
GET /session/{ session id session id }/element/{ element id element id }/selected Is Element Selected Is Element Selected
GET /session/{ session id session id }/element/{ element id element id }/attribute/{ name } Get Element Attribute Get Element Attribute
GET /session/{ session id session id }/element/{ element id element id }/property/{ name } Get Element Property Get Element Property
GET /session/{ session id session id }/element/{ element id element id }/css/{ property name property name } Get Element CSS Value Get Element CSS Value
GET /session/{ session id session id }/element/{ element id element id }/text Get Element Text Get Element Text
GET /session/{ session id session id }/element/{ element id element id }/name Get Element Tag Name Get Element Tag Name
GET /session/{ session id session id }/element/{ element id element id }/rect Get Element Rect Get Element Rect
GET /session/{ session id session id }/element/{ element id element id }/enabled Is Element Enabled Is Element Enabled
GET /session/{ session id session id }/element/{ element id element id }/computedrole Get Computed Role Get Computed Role
GET /session/{ session id session id }/element/{ element id element id }/computedlabel Get Computed Label Get Computed Label
POST /session/{ session id session id }/element/{ element id element id }/click Element Click Element Click
POST /session/{ session id session id }/element/{ element id element id }/clear Element Clear Element Clear
POST /session/{ session id session id }/element/{ element id element id }/value Element Send Keys Element Send Keys
GET /session/{ session id session id }/source Get Page Source Get Page Source
POST /session/{ session id session id }/execute/sync Execute Script Execute Script
POST /session/{ session id session id }/execute/async Execute Async Script Execute Async Script
GET /session/{ session id session id }/cookie Get All Cookies Get All Cookies
GET /session/{ session id session id }/cookie/{ name } Get Named Cookie Get Named Cookie
POST /session/{ session id session id }/cookie Add Cookie Add Cookie
DELETE /session/{ session id session id }/cookie/{ name } Delete Cookie Delete Cookie
DELETE /session/{ session id session id }/cookie Delete All Cookies Delete All Cookies
POST /session/{ session id session id }/actions Perform Actions Perform Actions
DELETE /session/{ session id session id }/actions Release Actions Release Actions
POST /session/{ session id session id }/alert/dismiss Dismiss Alert Dismiss Alert
POST /session/{ session id session id }/alert/accept Accept Alert Accept Alert
GET /session/{ session id session id }/alert/text Get Alert Text Get Alert Text
POST /session/{ session id session id }/alert/text Send Alert Text Send Alert Text
GET /session/{ session id session id }/screenshot Take Screenshot Take Screenshot
GET /session/{ session id session id }/element/{ element id element id }/screenshot Take Element Screenshot Take Element Screenshot
POST /session/{ session id session id }/print Print Page Print Page

6.6 6.6 Errors

Errors are represented in the WebDriver protocol by an HTTP response with an HTTP status in the 4xx or 5xx range, and a JSON body containing details of the are represented in the WebDriver protocol by an HTTP response with an HTTP status in the 4xx or 5xx range, and a JSON body containing details of the error . The body is a JSON . The body is a JSON Object and has a field named " and has a field named " value " whose value is an object bearing three, and sometimes four, fields: " whose value is an object bearing three, and sometimes four, fields:

The following table lists each error code , its associated HTTP status , JSON error code . Error Code HTTP Status JSON Error Code Description code, and a non-normative description of the error. The error response data for a particular error code is the values of the HTTP Status and JSON Error Code columns for the row corresponding to that error code .

Error Code HTTP Status JSON Error Code Description
element click intercepted 400 element click intercepted 400 element click intercepted The Element Click element click intercepted The Element Click command could not be completed because the could not be completed because the element receiving the events is receiving the events is obscuring the element that was requested clicked. the element that was requested clicked.
element not interactable 400 element not interactable 400 element not interactable A element not interactable A command could not be completed because the element is not could not be completed because the element is not pointer - or - or keyboard interactable . .
insecure certificate 400 insecure certificate 400 insecure certificate insecure certificate Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate. caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate.
invalid argument 400 invalid argument 400 invalid argument The arguments passed to a invalid argument The arguments passed to a command are either invalid or malformed. are either invalid or malformed.
invalid cookie domain 400 invalid cookie domain 400 invalid cookie domain An illegal attempt was made to set a cookie under a different domain than the current page. invalid cookie domain An illegal attempt was made to set a cookie under a different domain than the current page.
invalid element state 400 invalid element state 400 invalid element state A invalid element state A command could not be completed because the element is in an invalid state, e.g. attempting to could not be completed because the element is in an invalid state, e.g. attempting to clear an element that isn’t both an element that isn’t both editable and and resettable . .
invalid selector 400 invalid selector 400 invalid selector Argument was an invalid selector. invalid selector Argument was an invalid selector.
invalid session id 404 invalid session id 404 invalid session id Occurs if the given session id is not in the list of active sessions , meaning the invalid session id Occurs if the given session id is not in the list of active sessions , meaning the session either does not exist or that it’s not active. either does not exist or that it’s not active.
javascript error 500 javascript error 500 javascript error An error occurred while executing JavaScript supplied by the user. javascript error An error occurred while executing JavaScript supplied by the user.
move target out of bounds 500 move target out of bounds 500 move target out of bounds The target for mouse interaction is not in the browser’s viewport and cannot be brought into that viewport. move target out of bounds The target for mouse interaction is not in the browser’s viewport and cannot be brought into that viewport.
no such alert 404 no such alert 404 no such alert An attempt was made to operate on a modal dialog when one was not open. no such alert An attempt was made to operate on a modal dialog when one was not open.
no such cookie 404 no such cookie 404 no such cookie No cookie matching the given path name was found amongst the associated cookies of the current browsing context no such cookie No cookie matching the given path name was found amongst the associated cookies of session 's current browsing context ’s active document . ’s active document .
no such element 404 no such element 404 no such element An element could not be located on the page using the given search parameters. no such element An element could not be located on the page using the given search parameters.
no such frame 404 no such frame 404 no such frame A no such frame A command to switch to a frame could not be satisfied because the frame could not be found. to switch to a frame could not be satisfied because the frame could not be found.
no such window 404 no such window 404 no such window A no such window A command to switch to a window could not be satisfied because the window could not be found. to switch to a window could not be satisfied because the window could not be found.
no such shadow root 404 no such shadow root 404 no such shadow root The element does not have a shadow root. no such shadow root The element does not have a shadow root.
script timeout error 500 script timeout error 500 script timeout A script did not complete before its timeout expired. script timeout A script did not complete before its timeout expired.
session not created 500 session not created 500 session not created A new session not created A new session could not be created. could not be created.
stale element reference 404 stale element reference 404 stale element reference A stale element reference A command failed because the referenced failed because the referenced element is no longer attached to the DOM. is no longer attached to the DOM.
detached shadow root 404 detached shadow root 404 detached shadow root A detached shadow root A command failed because the referenced shadow root is no longer attached to the DOM. failed because the referenced shadow root is no longer attached to the DOM.
timeout 500 500 timeout An operation did not complete before its timeout expired. An operation did not complete before its timeout expired.
unable to set cookie 500 unable to set cookie 500 unable to set cookie A unable to set cookie A command to set a cookie’s value could not be satisfied. to set a cookie’s value could not be satisfied.
unable to capture screen 500 unable to capture screen 500 unable to capture screen A screen capture was made impossible. unable to capture screen A screen capture was made impossible.
unexpected alert open 500 unexpected alert open 500 unexpected alert open A modal dialog was open, blocking this operation. unexpected alert open A modal dialog was open, blocking this operation.
unknown command 404 unknown command 404 unknown command A unknown command A command could not be executed because the remote end is not aware of it. could not be executed because the remote end is not aware of it.
unknown error 500 unknown error 500 unknown error An unknown error occurred in the remote end while processing the unknown error An unknown error occurred in the remote end while processing the command . .
unknown method 405 unknown method 405 unknown method The requested unknown method The requested command matched a known URL but did not match any method for that URL. matched a known URL but did not match any method for that URL.
unsupported operation 500 unsupported operation 500 unsupported operation Indicates that a unsupported operation Indicates that a command that should have executed properly cannot be supported for some reason. An error data dictionary is a mapping of string keys to JSON serializable values that can optionally be included with that should have executed properly cannot be supported for some reason.

An error data dictionary is a mapping of string keys to JSON serializable values that can optionally be included with error objects. objects.

6.7 6.7 Extensions Using the terminology defined in this section, others may define additional commands that seamlessly integrate with the standard protocol. This allows vendors to expose functionality that is specific to their user agent, and it also allows other web standards to define commands for automating new platform features. Commands defined in this way are called extension commands and behave no differently than other

Using the terminology defined in this section, others may define additional commands that seamlessly integrate with the standard protocol. This allows vendors to expose functionality that is specific to their user agent, and it also allows other web standards to define commands for automating new platform features.

Commands defined in this way are called extension commands and behave no differently than other commands ; each has a dedicated HTTP endpoint and a set of remote end steps . Each extension command has an associated extension command URI Template that is a URI Template string, and which should bear some resemblance to what the command performs. This value, along with the HTTP method and extension command , is added to the table of endpoints and thus follows the same rules for request routing as that of other built-in ; each has a dedicated HTTP endpoint and a set of remote end steps .

Each extension command has an associated extension command URI Template that is a URI Template string, and which should bear some resemblance to what the command performs. This value, along with the HTTP method and extension command , is added to the table of endpoints and thus follows the same rules for request routing as that of other built-in commands . In order to avoid potential resource conflicts with other implementations, vendor-specific extension command URI Templates must begin with one or more path segments which uniquely identifies the vendor and UA. It is suggested that vendors use their vendor prefixes without additional characters as outlined in [ .

In order to avoid potential resource conflicts with other implementations, vendor-specific extension command URI Templates must begin with one or more path segments which uniquely identifies the vendor and UA. It is suggested that vendors use their vendor prefixes without additional characters as outlined in [ CSS21 ], notably in section 4.1.2.2 on vendor keywords ], notably in section 4.1.2.2 on vendor keywords , as the name for this path element, and include a vendor-chosen UA identifier. , as the name for this path element, and include a vendor-chosen UA identifier.

Note
If the extension command URI Template includes a variable named session id , the value of this variable will be used to define the current

Other specifications may define additional WebDriver capabilities . Each defined capability must have a capability name which is a string not containing a " : " (colon) character, an additional capability deserialization algorithm which is a set of steps taking a single argument " (colon) character, an additional capability deserialization algorithm which is a set of steps taking a single argument value which has a JSON type, returning either which has a JSON type, returning either success wrapping the deserialized capability value or wrapping the deserialized capability value or error . An additional WebDriver capability may also define a matched capability serialization algorithm , which is a set of steps used to determine if a capability is matched by the current implementation and provide any computed value to return to the user. This set of steps takes a single argument .

An additional WebDriver capability may also define a matched capability serialization algorithm , which is a set of steps used to determine if a capability is matched by the current implementation and provide any computed value to return to the user. This set of steps takes a single argument value , which is the output of the corresponding additional capability deserialization algorithm , and returns either , which is the output of the corresponding additional capability deserialization algorithm , and returns either null to indicate the capability is not matched, or a non-null JSON-serializable value if the capability is matched. Other specifications may also define WebDriver new session algorithms , which are called just after a new session is created, and before the new session response is sent to the remote end . These algorithms are called with session representing the WebDriver to indicate the capability is not matched, or a non-null JSON-serializable value if the capability is matched.

Other specifications may also define WebDriver new session algorithms , which are called just after a new session is created, and before the new session response is sent to the remote end . These algorithms are called with session that will be established, and capabilities , the capabilities object that will be returned to the remote end . It is permitted for such an algorithm to modify any entry in the representing the WebDriver session that will be established, and capabilities object with a name that's an additional WebDriver capability defined by the same specification. , the capabilities object that will be returned to the remote end . It is permitted for such an algorithm to modify any entry in the capabilities object with a name that's an additional WebDriver capability defined by the same specification.

Remote ends may also introduce extension capabilities that are extra Remote ends may also introduce extension capabilities that are extra capabilities used to provide configuration or fulfill other vendor-specific needs. Extension capabilities’ key must contain a " used to provide configuration or fulfill other vendor-specific needs. Extension capabilities’ key must contain a " : " (colon) character, denoting an implementation specific namespace. The value can be arbitrary JSON types. As with extension commands , it is suggested that the key used to denote the extension capability namespace is based on the vendor keywords listed in [ " (colon) character, denoting an implementation specific namespace. The value can be arbitrary JSON types.

As with extension commands , it is suggested that the key used to denote the extension capability namespace is based on the vendor keywords listed in [ CSS21 ] and precedes the first " ] and precedes the first " : " character in the string. " character in the string.

7. 7. Capabilities WebDriver capabilities are used to communicate the features supported by a given implementation. The local end may use capabilities to define which features it requires the remote end to satisfy when creating a new session . Likewise, the remote end uses

WebDriver capabilities to describe the full feature set for a are used to communicate the features supported by a given implementation. The local end may use capabilities to define which features it requires the remote end to satisfy when creating a new session . Likewise, the remote end uses capabilities to describe the full feature set for a session . The following table of standard capabilities enumerates the capabilities each implementation must support. An implementation may define additional extension capabilities . .

The following table of standard capabilities enumerates the capabilities each implementation must support. An implementation may define additional extension capabilities .

Capability Key Value Type Description
Browser name Browser name " browserName " string Identifies the user agent. " string Identifies the user agent.
Browser version Browser version " browserVersion " string Identifies the version of the user agent. " string Identifies the version of the user agent.
Platform name Platform name " platformName " string Identifies the operating system of the endpoint node . " string Identifies the operating system of the endpoint node .
Accept insecure TLS certificates Accept insecure TLS certificates " acceptInsecureCerts " boolean Indicates whether untrusted and self-signed TLS certificates are implicitly trusted on " boolean Indicates whether untrusted and self-signed TLS certificates are implicitly trusted on navigation for the duration of the for the duration of the session . .
Page load strategy Page load strategy " pageLoadStrategy " string Defines the current " string Defines the session ’s page load strategy . Proxy configuration ’s page load strategy .
Proxy configuration " proxy " JSON " JSON Object Defines the current Defines the session ’s proxy configuration . ’s proxy configuration .
Window dimensioning/positioning Window dimensioning/positioning " setWindowRect " boolean Indicates whether the remote end supports all of the resizing and repositioning " boolean Indicates whether the remote end supports all of the resizing and repositioning commands . .
Session timeouts Session timeouts " timeouts " JSON " JSON Object Describes the Describes the timeouts imposed on certain session operations. imposed on certain session operations.
Strict file interactability Strict file interactability " strictFileInteractability " boolean Defines the current " boolean Defines the session ’s strict file interactability . ’s strict file interactability .
Unhandled prompt behavior Unhandled prompt behavior " unhandledPromptBehavior " string Describes the current " string Describes the session ’s user prompt handler . Defaults to the dismiss and notify state . ’s user prompt handler . Defaults to the dismiss and notify state .

7.1 7.1 Proxy The proxy configuration capability is a JSON

The proxy configuration capability is a JSON Object nested within the primary nested within the primary capabilities . Implementations may define additional proxy configuration options, but they must not alter the semantics of those listed below. Key Value Type Description Valid values . Implementations may define additional proxy configuration options, but they must not alter the semantics of those listed below.

Key Value Type Description Valid values
proxyType string Indicates the type of proxy configuration. string Indicates the type of proxy configuration. " pac ", " ", " direct ", " ", " autodetect ", " ", " system ", or " ", or " manual ". ".
proxyAutoconfigUrl string Defines the URL for a proxy auto-config file if string Defines the URL for a proxy auto-config file if proxyType is equal to " is equal to " pac ". Any ". Any URL . .
ftpProxy string Defines the proxy string Defines the proxy host for FTP traffic when the for FTP traffic when the proxyType is " is " manual ". A host and optional port for scheme " ". A host and optional port for scheme " ftp ". ".
httpProxy string Defines the proxy string Defines the proxy host for HTTP traffic when the for HTTP traffic when the proxyType is " is " manual ". A host and optional port for scheme " ". A host and optional port for scheme " http ". ".
noProxy array Lists the address for which the proxy should be bypassed when the array Lists the address for which the proxy should be bypassed when the proxyType is " is " manual ". A ". A List containing any number of containing any number of String s. s.
sslProxy string Defines the proxy string Defines the proxy host for encrypted TLS traffic when the for encrypted TLS traffic when the proxyType is " is " manual ". A host and optional port for scheme " ". A host and optional port for scheme " https ". ".
socksProxy string Defines the proxy string Defines the proxy host for a SOCKS proxy when the for a SOCKS proxy when the proxyType is " is " manual ". A host and optional port with an ". A host and optional port with an undefined scheme. scheme.
socksVersion number Defines the SOCKS proxy version when the number Defines the SOCKS proxy version when the proxyType is " is " manual ". Any ". Any integer between 0 and 255 inclusive. A host and optional port for a between 0 and 255 inclusive.

A host and optional port for a scheme is defined as being a valid is defined as being a valid host , optionally followed by a colon and a valid , optionally followed by a colon and a valid port . The . The host may include credentials . If the port is omitted and may include credentials . If the port is omitted and scheme has a default port , this is the implied port. Otherwise, the port is left undefined. A has a default port , this is the implied port. Otherwise, the port is left undefined.

A proxyType of " of " direct " indicates that the browser should not use a proxy at all. A " indicates that the browser should not use a proxy at all.

A proxyType of " of " system " indicates that the browser should use the various proxies configured for the underlying Operating System. A " indicates that the browser should use the various proxies configured for the underlying Operating System.

A proxyType of " of " autodetect " indicates that the proxy to use should be detected in an implementation-specific way. The remote end steps to deserialize as a proxy argument " indicates that the proxy to use should be detected in an implementation-specific way.

The remote end steps to deserialize as a proxy argument parameter are: are:

  1. If If parameter is not a JSON is not a JSON Object return an error with return an error code invalid argument . with error code invalid argument .

  2. Let proxy be a new, empty Let proxy configuration object . be a new, empty proxy configuration object .

  3. For each enumerable own property in For each enumerable own property in parameter run the following substeps: run the following substeps:

    1. Let Let key be the name of the property. be the name of the property.

    2. Let Let value be the result of getting a property named be the result of getting a property named name from from parameter . .

    3. If there is no matching If there is no matching key for for key in the proxy configuration table return an error with in the proxy configuration table return an error code invalid argument . with error code invalid argument .

    4. If If value is not one of the valid values for that is not one of the valid values for that key , return an error with , return an error code invalid argument . with error code invalid argument .

    5. Set a property Set a property key to to value on on proxy . .

  4. If If proxy does not have an own property for " does not have an own property for " proxyType " return an error with " return an error code invalid argument . with error code invalid argument .

  5. If the result of getting a property named " If the result of getting a property named " proxyType " from " from proxy equals " equals " pac ", and ", and proxy does not have an own property for " does not have an own property for " proxyAutoconfigUrl " return an error with " return an error code invalid argument . with error code invalid argument .

  6. If If proxy has an own property for " has an own property for " socksProxy " and does not have an own property for " " and does not have an own property for " socksVersion " return an error with " return an error code invalid argument . with error code invalid argument .

  7. Return Return success with data proxy . A with data proxy configuration object is a JSON .

A proxy configuration object is a JSON Object where each of its own properties matching keys in the proxy configuration meets the validity criteria for that key. where each of its own properties matching keys in the proxy configuration meets the validity criteria for that key.

7.2 Processing capabilities 7.2 Processing capabilities To process capabilities with argument

To process capabilities with argument parameters , the endpoint node must take the following steps: , and flags , the endpoint node must take the following steps:

  1. Let capabilities request be the result of getting the property " Let capabilities request be the result of getting the property " capabilities " from " from parameters . .

    1. If capabilities request is not a JSON object, return error with If capabilities request is not a JSON object, return error code invalid argument . with error code invalid argument .

  2. Let required capabilities be the result of getting the property " Let required capabilities be the result of getting the property " alwaysMatch " from capabilities request . " from capabilities request .

    1. If required capabilities is If required capabilities is undefined , set the value to an empty JSON , set the value to an empty JSON Object . .

    2. Let required capabilities be the result of Let required capabilities be the result of trying to validate capabilities with argument required capabilities . to validate capabilities with argument required capabilities .

  3. Let all first match capabilities be the result of getting the property " Let all first match capabilities be the result of getting the property " firstMatch " from capabilities request . " from capabilities request .

    1. If all first match capabilities is If all first match capabilities is undefined , set the value to a JSON , set the value to a JSON List with a single entry of an empty JSON with a single entry of an empty JSON Object . .

    2. If all first match capabilities is not a JSON If all first match capabilities is not a JSON List with one or more entries, return error with with one or more entries, return error code invalid argument . with error code invalid argument .

  4. Let validated first match capabilities be an empty JSON Let validated first match capabilities be an empty JSON List . .

  5. For each first match capabilities corresponding to an indexed property in all first match capabilities : For each first match capabilities corresponding to an indexed property in all first match capabilities :

    1. Let validated capabilities be the result of Let validated capabilities be the result of trying to validate capabilities with argument first match capabilities . to validate capabilities with arguments first match capabilities and flags .

    2. Append validated capabilities to validated first match capabilities . Append validated capabilities to validated first match capabilities .

  6. Let merged capabilities be an empty Let merged capabilities be an empty List . .

  7. For each first match capabilities corresponding to an indexed property in validated first match capabilities : For each first match capabilities corresponding to an indexed property in validated first match capabilities :

    1. Let Let merged be the result of be the result of trying to merge capabilities with required capabilities and first match capabilities as arguments. to merge capabilities with required capabilities and first match capabilities as arguments.

    2. Append merged to Append merged capabilities . to merged capabilities .

  8. For each capabilities corresponding to an indexed property in merged For each capabilities : corresponding to an indexed property in merged capabilities :

    1. Let matched capabilities be the result of Let matched capabilities be the result of trying to match capabilities with to match capabilities with capabilities as an argument. as an argument.

    2. If matched capabilities is not If matched capabilities is not null , return , return success with data matched capabilities . with data matched capabilities .

  9. Return Return success with data with data null . When required to validate capabilities with argument .

When required to validate capabilities with argument capability : :

  1. If If capability is not a JSON is not a JSON Object return an error with return an error code invalid argument . with error code invalid argument .

  2. Let Let result be an empty JSON be an empty JSON Object . .

  3. For each enumerable own property in For each enumerable own property in capability , run the following substeps: , run the following substeps:

    1. Let name be the Let name of the property. be the name of the property.

    2. Let Let value be the result of getting a property named be the result of getting a property named name from from capability . .

    3. Run the substeps of the first matching condition: Run the substeps of the first matching condition:

      value is is null

      Let Let deserialized be set to be set to null . .

      name equals " equals " acceptInsecureCerts " "

      If If value is not a is not a boolean return an error with return an error code invalid argument . Otherwise, let with error code invalid argument . Otherwise, let deserialized be set to be set to value .

      name equals " equals " browserName " "
      name equals " equals " browserVersion " "
      name equals " equals " platformName " "

      If If value is not a is not a string return an error with return an error code invalid argument . Otherwise, let with error code invalid argument . Otherwise, let deserialized be set to be set to value . .

      name equals " equals " pageLoadStrategy " "

      Let Let deserialized be the result of be the result of trying to deserialize as a page load strategy with argument to deserialize as a page load strategy with argument value . .

      name equals " equals " proxy " "

      Let Let deserialized be the result of be the result of trying to deserialize as a proxy with argument to deserialize as a proxy with argument value . .

      name equals " equals " strictFileInteractability " "

      If If value is not a is not a boolean return an error with return an error code invalid argument . Otherwise, let with error code invalid argument . Otherwise, let deserialized be set to be set to value

      name equals " equals " timeouts " "

      Let Let deserialized be the result of be the result of trying to JSON deserialize as a timeouts configuration the to JSON deserialize as a timeouts configuration the value . .

      name equals " equals " unhandledPromptBehavior " "

      Let Let deserialized be the result of be the result of trying to deserialize as an unhandled prompt behavior with argument to deserialize as an unhandled prompt behavior with argument value . .

      name is the name of an additional WebDriver capability is the name of an additional WebDriver capability

      Let Let deserialized be the result of be the result of trying to run the additional capability deserialization algorithm for the extension capability corresponding to to run the additional capability deserialization algorithm for the extension capability corresponding to name , with argument , with argument value . .

      name is the key of an extension capability is the key of an extension capability

      If If name is known to the implementation, let is known to the implementation, let deserialized be the result of be the result of trying to deserialize to deserialize value in an implementation-specific way. Otherwise, let in an implementation-specific way. Otherwise, let deserialized be set to be set to value . The remote end is an endpoint node .

      The remote end is an endpoint node

      Return an error with Return an error code invalid argument . with error code invalid argument .

    4. If If deserialized is not is not null , set a property on , set a property on result with name with name name and value and value deserialized . Return .

  4. Return success with data with data result . When merging capabilities with JSON .

When merging capabilities with JSON Object arguments arguments primary and and secondary , an endpoint node must take the following steps: , an endpoint node must take the following steps:

  1. Let Let result be a new JSON be a new JSON Object . .

  2. For each enumerable own property in For each enumerable own property in primary , run the following substeps: , run the following substeps:

    1. Let name be the Let name of the property. be the name of the property.

    2. Let Let value be the result of getting a property named be the result of getting a property named name from from primary . .

    3. Set a property on Set a property on result with name with name name and value and value value . .
  3. If If secondary is is undefined , return , return result . .

  4. For each enumerable own property in For each enumerable own property in secondary , run the following substeps: , run the following substeps:

    1. Let name be the Let name of the property. be the name of the property.

    2. Let Let value be the result of getting a property named be the result of getting a property named name from from secondary . .

    3. Let primary value be the result of getting the property Let primary value be the result of getting the property name from from primary . .

    4. If primary value is not If primary value is not undefined , return an error with , return an error code invalid argument . with error code invalid argument .

    5. Set a property on Set a property on result with name with name name and value and value value . .
  5. Return Return result . .

Note
The algorithm outlined in matching capabilities blithely ignores real-world problems that make implementation less than perfectly straightforward, particularly since capabilities can interact in unforeseen ways. As an example, an implementation could have a capability that gives the path to the browser binary to use. This could cause both When matching capabilities with JSON

When matching capabilities given JSON Object argument capabilities , an endpoint node must take the following steps: , and a set flags , an endpoint node must take the following steps:

  1. Let matched capabilities be a JSON Let matched capabilities be a JSON Object with the following entries: with the following entries:

    " browserName " "
    ASCII Lowercase name of the user agent as a ASCII Lowercase name of the user agent as a string . .
    " browserVersion " The user agent version, as a "
    The user agent version, as a string . .
    " platformName " "
    ASCII Lowercase name of the current platform as a ASCII Lowercase name of the current platform as a string . .
    " acceptInsecureCerts " "
    Boolean initially set to false, indicating the session will not implicitly trust untrusted or self-signed TLS certificates on initially set to false, indicating the session will not implicitly trust untrusted or self-signed TLS certificates on navigation . .
    " strictFileInteractability setWindowRect " "
    Boolean indicating whether the remote end supports all of the resizing and positioning commands .
  2. Boolean initially set to false, indicating that interactabilty checks will be applied to <input type=file>. "

    If flags contains " setWindowRect http ", add the following entries to matched capabilities :

    " strictFileInteractability "
    Boolean indicating whether the remote end supports all of the resizing and positioning commands . initially set to false, indicating that interactabilty checks will be applied to <input type=file>.
  3. Optionally add extension capabilities as entries to matched capabilities . The values of these may be elided, and there is no requirement that all extension capabilities be added. Optionally add extension capabilities as entries to matched capabilities . The values of these may be elided, and there is no requirement that all extension capabilities be added.

    Note
    This allows a remote end to add information that might be useful to a local end without unnecessarily bloating the response sent back to the user with (e.g.) an entire browser profile. For example, an implementation could choose to indicate that a screenshot will be taken when returning an error by setting the capability
  4. For each For each name and and value corresponding to corresponding to capability ’s own properties : ’s own properties :

    1. Let match value equal Let match value equal value . .

    2. Run the substeps of the first matching Run the substeps of the first matching name : :

      " browserName " "

      If If value is not a string equal to the " is not a string equal to the " browserName " entry in matched capabilities , return " entry in matched capabilities , return success with data with data null . .

      Note

      There is a chance the remote end will need to start a browser process to correctly determine the There is a chance the remote end will need to start a browser process to correctly determine the browserName . Lightweight checks are preferred before this is done. . Lightweight checks are preferred before this is done.

      " browserVersion " "

      Compare Compare value to the " to the " browserVersion " entry in matched capabilities using an implementation-defined comparison algorithm. The comparison is to accept a " entry in matched capabilities using an implementation-defined comparison algorithm. The comparison is to accept a value that places constraints on the version using the " that places constraints on the version using the " < ", " ", " <= ", " ", " > ", and " ", and " >= " operators. If the two values do not match, return " operators.

      If the two values do not match, return success with data with data null . .

      Note

      Version comparison is left as an implementation detail since each user agent will likely have conflicting methods of encoding the user agent version, and standardizing these schemes is beyond the scope of this standard. Version comparison is left as an implementation detail since each user agent will likely have conflicting methods of encoding the user agent version, and standardizing these schemes is beyond the scope of this standard.

      Note

      There is a chance the remote end will need to start a browser process to correctly determine the There is a chance the remote end will need to start a browser process to correctly determine the browserVersion . Lightweight checks are preferred before this is done. . Lightweight checks are preferred before this is done.

      " platformName " "

      If If value is not a string equal to the " is not a string equal to the " platformName " entry in matched capabilities , return " entry in matched capabilities , return success with data with data null . .

      Note
      The following platform names are in common usage with well-understood semantics and, when matching capabilities , greatest interoperability can be achieved by honoring them as valid synonyms for well-known Operating Systems: Key System

      The following platform names are in common usage with well-understood semantics and, when matching capabilities , greatest interoperability can be achieved by honoring them as valid synonyms for well-known Operating Systems:

      Key System
      " linux " Any server or desktop system based upon the Linux kernel. Any server or desktop system based upon the Linux kernel.
      " mac " Any version of Apple’s macOS. Any version of Apple’s macOS.
      " windows " Any version of Microsoft Windows, including desktop and mobile versions. This list is not exhaustive. When returning Any version of Microsoft Windows, including desktop and mobile versions.

      This list is not exhaustive.

      When returning capabilities from New Session , it is valid to return a more specific from New Session , it is valid to return a more specific platformName , allowing users to correctly identify the Operating System the WebDriver implementation is running on. , allowing users to correctly identify the Operating System the WebDriver implementation is running on.

      " acceptInsecureCerts " "

      If If accept insecure TLS flag is set and not equal to value is true and the endpoint node does not support insecure TLS certificates , return , return success with data with data null . .

      Note

      If the endpoint node does not support insecure TLS certificates and this is the reason no match is ultimately made, it is useful to provide this information to the local end . If the endpoint node does not support insecure TLS certificates and this is the reason no match is ultimately made, it is useful to provide this information to the local end .

      " proxy " "

      If the endpoint node does not allow the proxy it uses to be configured, or if the proxy configuration defined in If the has proxy configuration flag is set, or if the proxy configuration defined in value is not one that passes the endpoint node is not one that passes the endpoint node ’s implementation-specific validity checks, return ’s implementation-specific validity checks, return success with data with data null . .

      Note

      A local end would only send this capability if it expected it to be honored and the configured proxy used. The intent is that if this is not possible a new session will not be established. A local end would only send this capability if it expected it to be honored and the configured proxy used. The intent is that if this is not possible a new session will not be established.

      Otherwise If name is the
    3. Set a property on matched capabilities with name If match value is not null, set a property on matched capabilities with name name and value match value . and value match value .

  5. Return Return success with data matched capabilities . with data matched capabilities .

8. 8. Sessions A session is equivalent to a single instantiation of a particular user agent, including all its child browsers. WebDriver gives each session a unique session ID that can be used to differentiate one

A WebDriver session from another, allowing multiple user agents to be controlled from a single HTTP server, and allowing sessions to be routed via a multiplexer (known as an intermediary node ). A WebDriver represents the logical connection between a local end and a specific remote end . The session represents the connection between a local end and a specific remote end . A object holds state specific to that connection.

An intermediary node will maintain an associated session for each active session is started when a New Session is invoked. It is an error to send any commands before starting a session, or to continue to send commands after the . This is the session has been closed. Maintaining on the upstream neighbor that is created when the intermediary node executes the New Session command . Closing a session continuity between commands to the remote end requires passing a on an intermediary node will also close the session of the associated session .

A session ID . A has a session ID , which is the string representation of a UUID used to uniquely identify the session. This is set when creating the session.

A session is torn down at some later point; either explicitly by invoking Delete Session , or implicitly when Close Window is called at the last remaining top-level browsing context . An intermediary node will maintain an associated has a HTTP flag which is set when the session is created. A session with this flag set is a HTTP session .

A session for each active has an associated list of active input sources .

A session . This is the has an associated input state table .

A session on the upstream neighbor that is created when the intermediary node executes the New Session command . Closing a has an associated input cancel list .

A remote end has an associated list of active sessions , which is a list of all session on an intermediary node s that are currently started.

A remote end has an associated list of active HTTP sessions , which is a list of all HTTP session will also close the session s that are currently started.

Note

The limitation of a single HTTP session for endpoint node of the associated session . s means that the first entry in the list of active HTTP sessions will be the only entry.

All A HTTP session has an associated current browsing context , which is the browsing context against which commands , except New Session and Status , have an associated current session , which is the session in which that command will run. A remote end has an associated list of active sessions , which is a list of all sessions that are currently started. A remote end that is not an intermediary node has at most one active session will run, an associated current parent browsing context , which is set to the parent of the current browsing context when changing browsing contexts, and an associated current top-level browsing context , which is set to the top-browsing context ancestor of the current browsing context , when changing browsing contexts.

An HTTP session has an associated session timeouts that records the timeout duration values used to control the behavior of script evaluation , navigation , and element retrieval .

An HTTP session has an associated page loading strategy , which is one of the keywords from the table of page load strategies . Unless stated otherwise, it is normal .

An HTTP session has an associated strict file interactability state which is a boolean.

A HTTP session has an associated user prompt handler . Unless stated otherwise it is in the dismiss and notify state .

An HTTP session has an associated request queue which is a queue of requests that are currently awaiting processing.

Global State at a given time.

In addition to per-session state, a remote end that is an endpoint node also has additional state that is global across all sessions.

An endpoint node has an associated accept insecure TLS flag that indicates whether untrusted or self-signed TLS certificates are treated as trusted. The default value of the flag is false if the endpoint doesn't support accepting insecure TLS connections, or unset otherwise.

An endpoint node has an associated has proxy configuration flag that indicates whether the proxy is already configured. The default value of the flag is true if the endpoint doesn't support proxy configuration, or false otherwise.

To create a session , given a JSON Object capabilites , and a set flags :

  1. A remote end has an associated maximum active sessions (an integer) that defines the number of active sessions that are supported. This may be “unlimited” for intermediary nodes , but must be exactly one for a remote end that is an endpoint node . Let session id be the result of generating a UUID .

  2. A Let session has an associated be a new session ID (a string representation of a UUID ) used to uniquely identify this session. Unless stated otherwise it is with session ID session id , and HTTP flag flags contains " http ".

  3. Let proxy be the result of getting property " null proxy " from capabilities and run the substeps of the first matching statement:

    proxy is a proxy configuration object

    Take implementation-defined steps to set the user agent proxy using the extracted proxy configuration. If the defined proxy cannot be configured return error with error code session not created . Otherwise set the has proxy configuration flag to true.

    Otherwise
    Set a property of capabilities with name " proxy " and a value that is a new JSON Object .
  4. A session has an associated current browsing context , which is the browsing context against which commands will run, an associated current parent browsing context , which is set to the parent of the current browsing context If capabilites has a property named " acceptInsecureCerts ", set the endpoint node when changing browsing contexts, and an associated current top-level browsing context , which is set to the top-browsing context ancestor of the current browsing context , when changing browsing contexts. 's accept insecure TLS flag to the result of getting a property named " acceptInsecureCerts " from capabilities .

  5. A session has an associated session timeouts that records the timeout duration values used to control the behavior of script evaluation , navigation , and element retrieval . If flags contains " http ":

    1. A Let strategy be the result of getting property " pageLoadStrategy " from capabilities .

      If strategy is a string, set the session has an associated page loading ’s page loading strategy to strategy , which is one of the keywords from the table of page load strategies . Unless stated otherwise, it is . Otherwise, set the page loading strategy to normal . and set a property of capabilities with name " pageLoadStrategy " and value " normal ".

    2. A Let strictFileInteractability be the result of getting property " strictFileInteractability " from capabilities . If strictFileInteractability is a boolean, set session has an associated secure TLS state that indicates whether untrusted or self-signed TLS certificates should be trusted for the duration of the WebDriver session. If it is unset, this indicates that certificate- or TLS errors that occur upon navigation ’s strict file interactability to strictFileInteractability . Otherwise set session should be suppressed. The state can be unset by providing an " ’s strict file interactability to false.

    3. If capabilities has a property with the key " acceptInsecureCerts timeouts " capability with the value true. Unless stated otherwise, it is set. ":

      1. A session has an associated strict file interactability state which is a boolean. Let timeouts be the result of trying to JSON deserialize as a timeouts configuration the value of the " timeouts " property.

      2. A session has an associated user prompt handler . Unless stated otherwise it is in the dismiss and notify state . Make the session timeouts the new timeouts .

    4. A session has an associated list of active input sources . Set a property on capabilities with name " timeouts " and value that of the JSON deserialization of the session timeouts .

  6. A Process any extension capabilities in capabilities in an implementation-defined manner.

  7. Run any WebDriver new session algorithm defined in external specifications, with arguments session has an associated input state table . , capabilities , and flags .

  8. Append session to active sessions .
  9. If flags contains " http ", append session to active HTTP sessions .
  10. A Set the webdriver-active flag to true.

To close the session , given session has an associated input cancel list . a remote end must take the following steps:

  1. A If session has an associated request queue which is a queue of requests that are currently awaiting processing. 's HTTP flag is set, remove session from active HTTP sessions .

  2. When asked to close the Remove session , a remote end must take the following steps: from active sessions .

  3. Perform the following substeps based on the remote end Perform the following substeps based on the remote end ’s type: ’s type:

    Remote end is an endpoint node Remote end is an endpoint node
    1. If the list of active sessions is empty, set the webdriver-active flag to false.

    2. Unset the accept insecure TLS

      flag.
    3. Set the webdriver-active flag Reset the has proxy configuration to false.

      flag to its default value.
    4. An endpoint node must If active sessions is empty, pptionally, close any top-level browsing contexts associated with the session , without prompting to unload . all top-level browsing contexts , without prompting to unload .

    Remote end is an intermediary node Remote end is an intermediary node
    1. Close the associated session . If this causes an the associated session . If this causes an error to occur, complete the remainder of this algorithm before returning the to occur, complete the remainder of this algorithm before returning the error . Remove the current session from active sessions . .

  4. Perform any implementation-specific cleanup steps. Perform any implementation-specific cleanup steps.

  5. If an If an error has occurred in any of the steps above, return the has occurred in any of the steps above, return the error , otherwise return , otherwise return success with data with data null . Closing a .

Closing a session might cause the associated browser process to be killed. It is assumed that any implementation-specific cleanup steps are performed might cause the associated browser process to be killed. It is assumed that any implementation-specific cleanup steps are performed after the response has been sent back to the client so that the the response has been sent back to the client so that the connection is not prematurely closed. 8.1 is not prematurely closed.

New Session New Session HTTP Method URI Template

HTTP Method URI Template
POST /session The New Session

The New Session command creates a new WebDriver session with the endpoint node . If the creation fails, a creates a new WebDriver session not created with the endpoint node . If the creation fails, a session not created error is returned. If the remote end is an intermediary node , it may use the result of the capabilities processing algorithm to route the new session request to the appropriate endpoint node . An intermediary node is free to define extension capabilities to assist in this process, however, these specific capabilities must not be forwarded to the endpoint node . If the intermediary node requires additional information unrelated to user agent features, it is recommended that this information be passed as top-level parameters, and not as part of the requested is returned.

If the remote end is an intermediary node , it may use the result of the capabilities processing algorithm to route the new session request to the appropriate endpoint node . An intermediary node is free to define extension capabilities to assist in this process, however, these specific capabilities must not be forwarded to the endpoint node .

If the intermediary node requires additional information unrelated to user agent features, it is recommended that this information be passed as top-level parameters, and not as part of the requested capabilities . An intermediary node must forward custom, top-level parameters (i.e. non- . An intermediary node must forward custom, top-level parameters (i.e. non- capabilities ) to subsequent remote end nodes. ) to subsequent remote end nodes.

The remote end steps , given session , URL variables and parameters are:

  1. If the maximum active sessions is equal to the length of the list of active sessions , return error with If the implementation is an endpoint node , and the list of active HTTP sessions is not empty, or otherwise if the implementation is unable to start an additional session, return error code session not created . with error code session not created .

  2. If the remote end is an intermediary node , take implementation-defined steps that either result in returning an error with If the remote end is an intermediary node , take implementation-defined steps that either result in returning an error code session not created , or in returning a with error code session not created , or in returning a success with data that is isomorphic to that returned by remote ends according to the rest of this algorithm. If an with data that is isomorphic to that returned by remote ends according to the rest of this algorithm. If an error is not returned, the intermediary node must retain a reference to the is not returned, the intermediary node must retain a reference to the session created on the created on the upstream node as the associated session such that commands may be forwarded to this associated session on subsequent commands. node as the associated session such that commands may be forwarded to this associated session on subsequent commands.

    Note

    How this is done is entirely up to the implementation, but typically the How this is done is entirely up to the implementation, but typically the sessionId , and URL and , and URL prefix of the and URL prefix of the upstream remote end will need to be tracked. remote end will need to be tracked.

  3. If the maximum active sessions is equal to the length of the list of active sessions , return error with error code session not created . Let flags be a set containing " http ".

  4. Let Let capabilities be the result of be the result of trying to process capabilities with to process capabilities with parameters as an argument. and flags .

  5. If If capabilities ’s is ’s is null , return error with , return error code session not created . Let session id be the result of generating a UUID . Let session be a new session with the session ID of session id . Set the current session to session . with error code session not created .

  6. Run any WebDriver new session algorithm defined in external specifications, with arguments Let session and be the result of create a session , with capabilities . Append session to active sessions . , and flags .

  7. Let Let body be a JSON be a JSON Object initialized with: initialized with:

    " sessionId " session id " capabilities " capabilities Initialize the following from capabilities : Let strategy be the result of getting property " pageLoadStrategy " from capabilities . If strategy is a string, set the current session ’s page loading strategy to strategy . Otherwise, set the page loading strategy to normal and set a property of capabilities with name " pageLoadStrategy " and value " normal ". Let strictFileInteractability be the result of getting property " strictFileInteractability " from capabilities . "
    If strictFileInteractability is a boolean, set the current session ’s strict file interactability to strictFileInteractability . Otherwise set the current session ’s strict file interactability to false. Let proxy be the result of getting property 's session ID .
    " proxy " from capabilities and run the substeps of the first matching statement: proxy is a proxy configuration object Take implementation-defined steps to set the user agent proxy using the extracted proxy configuration. If the defined proxy cannot be configured return error with error code session not created . Otherwise Set a property of capabilities with name " proxy " and a value that is a new JSON Object . "
    If capabilities has a property with the key " timeouts ": Let timeouts be the result of trying to JSON deserialize as a timeouts configuration the value of the " timeouts " property. Make the session timeouts the new timeouts .
  8. Set a property on capabilities with name " timeouts " and value that of the JSON deserialization of the Set the current top-level browsing context of session timeouts . Apply changes to the user agent for any implementation-defined capabilities selected during the capabilities processing step. Set the webdriver-active flag to true. Set the current top-level browsing context to one of the endpoint node for session with the top-level browsing context 's top-level browsing context of the UA’s current browsing context . s, preferring the top level browsing context that has system focus , or otherwise preferring any top level browsing context whose visibility state is visible .

    Note

    WebDriver implementations typically start a completely new browser instance, but there is no requirement in this specification (or for WebDriver only to be used to automate only web browsers). Implementations might choose to use an existing browser instance, eg. by selecting the window that currently has focus. WebDriver implementations typically start a completely new browser instance, but there is no requirement in this specification (or for WebDriver only to be used to automate only web browsers). Implementations might choose to use an existing browser instance, eg. by selecting the window that currently has focus.

  9. Set the request queue to a new Set the request queue to a new queue . .

  10. Return Return success with data with data body . 8.2 .

Delete Session Delete Session HTTP Method URI Template

HTTP Method URI Template
DELETE /session/{ session id session id } The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current session is an active If session , is an active HTTP session , try to close the to close the session with session . .

  2. Return Return success with data with data null . 8.3 .

Status HTTP Method URI Template

HTTP Method URI Template
GET /status
Note
Implementations may optionally include additional meta information as part of the body, but the top-level properties

Implementations may optionally include additional meta information as part of the body, but the top-level properties ready and and message are reserved and must not be overwritten. The remote end steps are: are reserved and must not be overwritten.

The remote end steps , given session , URL variables and parameters are:

  1. Let Let body be a new JSON be a new JSON Object with the following properties: with the following properties:

    " ready " "

    The remote end The remote end ’s readiness state . ’s readiness state .

    " message " "

    An implementation-defined string explaining the remote end An implementation-defined string explaining the remote end ’s readiness state . ’s readiness state .

  2. Return Return success with data with data body . .

9. 9. Timeouts A timeouts configuration is a record of the different timeouts that control the behavior of script evaluation ,

A timeouts configuration is a record of the different timeouts that control the behavior of script evaluation , navigation , and element retrieval : Field Default JSON key , and element retrieval :

Field Default JSON key Optional Nullable Nullable Description
Script timeout 30,000 Script timeout 30,000 " script " ✓ ✓ Specifies when to interrupt a script that is being "

Specifies when to interrupt a script that is being evaluated . A .

A null value implies that scripts should never be interrupted, but instead run indefinitely. value implies that scripts should never be interrupted, but instead run indefinitely.

Page load timeout 300,000 Page load timeout 300,000 " pageLoad " ✓ Provides the timeout limit used to interrupt an explicit "

Provides the timeout limit used to interrupt an explicit navigation attempt. attempt.

Implicit wait timeout 0 Implicit wait timeout 0 " implicit " ✓ Specifies a time to wait for the element location strategy to complete when locating an element "

Specifies a time to wait for the element location strategy to complete when locating an element

Informative. The timeouts object for a timeouts configuration timeouts is an Informative.

The timeouts object for a timeouts configuration timeouts is an object initalized with the following properties: initalized with the following properties:

" script " "
timeouts ' script timeout value, if set, or its default value. ' script timeout value, if set, or its default value.
" pageLoad " "
timouts ' page load timeout ' page load timeout ’s value, if set, or its default value. ’s value, if set, or its default value.
" implicit " "
timeouts ' implicit wait timeout ’s value, if set, or its default value. To JSON deserialize ' implicit wait timeout an input ’s value, if set, or its default value.

To JSON deserialize an input value into a timeouts configuration record: into a timeouts configuration record:

  1. Let timeouts be a new

    Let timeouts configuration . be a new timeouts configuration .

  2. If

    If value is not a JSON is not a JSON Object , return error with , return error code invalid argument . with error code invalid argument .

  3. If

    If value has a property with the key " has a property with the key " script ": ":

    1. Let script duration be the value of property "

      Let script duration be the value of property " script ". ".

    2. If script duration is a number and less than 0 or greater than maximum safe integer , or it is not

      If script duration is a number and less than 0 or greater than maximum safe integer , or it is not null , return error with , return error code invalid argument . with error code invalid argument .

    3. Set

      Set timeouts ’s script timeout to script duration . ’s script timeout to script duration .

  4. If

    If value has a property with the key " has a property with the key " pageLoad ": ":

    1. Let page load duration be the value of property "

      Let page load duration be the value of property " pageLoad ". ".

    2. If page load duration is less than 0 or greater than maximum safe integer , return error with

      If page load duration is less than 0 or greater than maximum safe integer , return error code invalid argument . with error code invalid argument .

    3. Set

      Set timeouts ’s page load timeout to page load duration . ’s page load timeout to page load duration .

  5. If

    If value has a property with the key " has a property with the key " implicit ": ":

    1. Let implicit duration be the value of property "

      Let implicit duration be the value of property " implicit ". ".

    2. If implicit duration is less than 0 or greater than maximum safe integer , return error with

      If implicit duration is less than 0 or greater than maximum safe integer , return error code invalid argument . with error code invalid argument .

    3. Set

      Set timeouts ’s implicit wait timeout to implicit duration . ’s implicit wait timeout to implicit duration .

  6. Return

    Return success with data with data timeouts . .

9.1 9.1 Get Timeouts Get Timeouts HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/timeouts The remote end step are:

The remote end steps , given session , URL variables and parameters are:

  1. Let timeouts be the Let timeouts object for be the timeouts object for session ’s timeouts configuration ’s timeouts configuration

  2. Return Return success with data with data timeouts . .

9.2 9.2 Set Timeouts Set Timeouts HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/timeouts The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. Let

    Let timeouts be the result of be the result of trying to JSON deserialize as a timeouts configuration the request’s to JSON deserialize as a timeouts configuration with parameters . .

  2. Make the session timeouts the new

    Make the session timeouts the new timeouts . .

  3. Return

    Return success with data with data null . .

11. 11. Contexts Many WebDriver

Many WebDriver commands happen in the context of either the current browsing context or current top-level browsing context . The current top-level browsing context is represented in the protocol by its associated window handle . When a top-level browsing context is selected using the Switch To Window command, a specific browsing context can be selected using the Switch to Frame command. happen in the context of either session 's current browsing context or current top-level browsing context . session's current top-level browsing context is represented in the protocol by its associated window handle . When a top-level browsing context is selected using the Switch To Window command, a specific browsing context can be selected using the Switch to Frame command.

Note

The use of the term “window” to refer to a top-level browsing context is legacy and doesn’t correspond with either the operating system notion of a “window” or the DOM The use of the term “window” to refer to a top-level browsing context is legacy and doesn’t correspond with either the operating system notion of a “window” or the DOM Window object. object.

A browsing context is said to be no longer open if it has been A browsing context is said to be no longer open if it has been discarded . Each browsing context has an associated window handle which uniquely identifies it. This must be a .

Each browsing context has an associated window handle which uniquely identifies it. This must be a String and must not be " and must not be " current ". The web window identifier is the string constant " ".

The web window identifier is the string constant " window-fcc6-11e5-b4f8-330a88ab9d7f ". The web frame identifier is the string constant " ".

The web frame identifier is the string constant " frame-075b-4da1-b6ba-e579c2d3230a ". The ".

The WindowProxy reference object with reference object with WindowProxy object object window is given by: is given by:

  1. Let identifier be the web window Let identifier if the associated browsing context of be the web window identifier if the associated browsing context of window is a top-level browsing context . Otherwise let it be the web frame identifier . is a top-level browsing context .

    Otherwise let it be the web frame identifier .

  2. Return a JSON Return a JSON Object initialised with the following properties: initialised with the following properties:

    identifier

    Associated window handle of the Associated window handle of the window ’s browsing ’s browsing context .

When required to set the current browsing context given session and context . , an implementation must follow the following steps:

  1. When required to set the current browsing context given a Set session’s current browsing context to context , an implementation must follow the following steps: .

  2. Set the current

    Set the session ’s current browsing context to ’s current parent browsing context to the parent browsing context of context . Set the current , if that context exists, or null otherwise.

When required to set the current top-level browsing context given session ’s current parent browsing context to the parent browsing context of context , if that and context exists, or null otherwise. , an implementation must:

  1. When required to set the current top-level browsing context given a context , an implementation must follow the following steps: Assert: context is a top-level browsing Assert: context . Set the current is a top-level browsing context .

  2. Set session ’s current top-level browsing context to ’s current top-level browsing context to context . .

  3. Set the current browsing context to Set the current browsing context with session and context . .

Note
In accordance with the

In accordance with the focus section of the [ section of the [ HTML ] specification, commands are unaffected by whether the operating system window has focus or not. ] specification, commands are unaffected by whether the operating system window has focus or not.

11.1 11.1 Get Window Handle Get Window Handle HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/window The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

  2. Return Return success with data being the window handle associated with the current top-level browsing context . with data being the window handle associated with session's current top-level browsing context .

11.2 11.2 Close Window Close Window HTTP Method URI Template

HTTP Method URI Template
DELETE /session/{ session id session id }/window The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Close the current top-level browsing context . session's current top-level browsing context .

  4. If there are no more open top-level browsing contexts , then If there are no more open top-level browsing contexts , then try to close the session . Return the result of running the remote end steps for the Get Window Handles to close the session .

  5. Return the result of running the remote end steps for the Get Window Handles command . , with session , URL variables and parameters .

11.3 11.3 Switch To Window Switch To Window HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/window
Note
Switching window will select the current top-level browsing context used as the target for all subsequent

Switching window will select session's current top-level browsing context used as the target for all subsequent commands . In a tabbed browser, this will typically make the tab containing the browsing context the selected tab. . In a tabbed browser, this will typically make the tab containing the browsing context the selected tab.

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. Let Let handle be the result of getting the property " be the result of getting the property " handle " from the " from parameters argument. .

  2. If If handle is is undefined , return error with , return error code invalid argument . with error code invalid argument .

  3. If there is an active user prompt , that prevents the focussing of another top-level browsing context , return error with If there is an active user prompt , that prevents the focussing of another top-level browsing context , return error code unexpected alert open . with error code unexpected alert open .

  4. If handle is equal to the associated window If handle for some top-level browsing is equal to the associated window handle for some top-level browsing context , let context in the current be the that browsing context, and set the current top-level browsing context with session , let context be the that browsing context, and set the current top-level browsing context with and context . Otherwise, return error with .

    Otherwise, return error code no such window . with error code no such window .

  5. Update any implementation-specific state that would result from the user selecting the current browsing context for interaction, without altering OS-level focus. Update any implementation-specific state that would result from the user selecting session 's current browsing context for interaction, without altering OS-level focus.

  6. Return Return success with data with data null . .

11.4 11.4 Get Window Handles Get Window Handles HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/window/handles The order in which the window handles are returned is arbitrary. The remote end steps are:

The order in which the window handles are returned is arbitrary.

The remote end steps , given session , URL variables and parameters are:

  1. Let Let handles be a JSON be a JSON List . .

  2. For each top-level browsing context in the remote end , push the associated window handle onto For each top-level browsing context in the remote end , push the associated window handle onto handles . Return .

  3. Return success with data with data handles . .

11.5 11.5 New Window New Window HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/window/new Create a new top-level browsing context . The remote end steps are:

Create a new top-level browsing context .

The remote end steps , given session , URL variables and parameters are:

  1. If the implementation does not support creating new top-level browsing contexts, return error with If the implementation does not support creating new top-level browsing contexts, return error code unsupported operation . with error code unsupported operation .

  2. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

  3. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  4. Let type hint be the result of getting the property " Let type hint be the result of getting the property " type " from the " from parameters argument. .

  5. Create a new top-level browsing context by running the window open steps with url set to " Create a new top-level browsing context by running the window open steps with URL set to " about:blank ", ", target set to the empty string, and set to the empty string, and features set to " set to " noopener " and the user agent configured to create a new browsing context. This must be done without invoking the focusing steps for the created browsing context. If type hint has the value " " and the user agent configured to create a new browsing context. This must be done without invoking the focusing steps for the created browsing context. If type hint has the value " tab ", and the implementation supports multiple browsing context in the same OS window, the new browsing context should share an OS window with the current browsing context . If type hint ", and the implementation supports multiple browsing context in the same OS window, the new browsing context should share an OS window with session is " 's current browsing context . If type hint is " window ", and the implementation supports multiple browsing contexts in separate OS windows, the created browsing context should be in a new OS window. In all other cases the details of how the browsing context is presented to the user are implementation defined. ", and the implementation supports multiple browsing contexts in separate OS windows, the created browsing context should be in a new OS window. In all other cases the details of how the browsing context is presented to the user are implementation defined.

  6. Let handle be the associated window Let handle of the newly created window. be the associated window handle of the newly created window.

  7. Let Let type be " be " tab " if the newly created window shares an OS-level window with the current browsing context , or " " if the newly created window shares an OS-level window with the current browsing context , or " window " otherwise. " otherwise.

  8. Let Let result be a new JSON be a new JSON Object initialised with: initialised with:

    " handle " The value of "
    The value of handle . .
    " type " The value of "
    The value of type . .
  9. Return Return success with data with data result . .

11.6 11.6 Switch To Frame Switch To Frame HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/frame
Note

The Switch To Frame command is used to select the current top-level browsing context or a child browsing context of the current browsing context to use as the current browsing context for subsequent The Switch To Frame command is used to select session's current top-level browsing context or a child browsing context of session 's current browsing context to use as session 's current browsing context for subsequent commands . . The remote end steps , given session , URL variables and parameters are:

The remote end steps are:
  1. Let Let id be the result of getting the property " be the result of getting the property " id " from the " from parameters argument. .

  2. If If id is not is not null , a , a Number object, or an object, or an Object that represents a web element , return error with that represents a web element , return error code invalid argument . with error code invalid argument .

  3. Run the substeps of the first matching condition: Run the substeps of the first matching condition:

    id is is null
    1. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

    2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

    3. Set the current browsing context with the current top-level browsing context . Set the current browsing context with session and the current top-level browsing context .

    id is a is a Number object object
    1. If If id is less than 0 or greater than 2 is less than 0 or greater than 2 16 – 1, return error with – 1, return error code invalid argument . with error code invalid argument .

    2. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

    3. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

    4. Let Let window be the associated window of session be the associated window of the current browsing context 's current browsing context ’s active document . ’s active document .

    5. If If id is not a supported property index of is not a supported property index of window , return error with , return error code no such frame . with error code no such frame .

    6. Let child window be the Let child window be the WindowProxy object obtained by calling object obtained by calling window . [[GetOwnProperty]] ( ( id ). ).

    7. Set the current browsing context with child window Set the current browsing context with session and child window ’s browsing context . ’s browsing context .

    id represents a web element represents a web element
    1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

    2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

    3. Let Let element be the result of be the result of trying to get a known element by web element reference to get a known element by web element reference id . .

    4. If If element is stale , return error with is stale , return error code stale element reference . with error code stale element reference .

    5. If If element is not a is not a frame or or iframe element, return error with element, return error code no such frame . with error code no such frame .

    6. Set the current browsing context with Set the current browsing context with element ’s nested browsing context . ’s nested browsing context .

  4. Update any implementation-specific state that would result from the user selecting the current browsing context for interaction, without altering OS-level focus. Update any implementation-specific state that would result from the user selecting session 's current browsing context for interaction, without altering OS-level focus.

  5. Return Return success with data with data null . .

Note

WebDriver is not bound by the same origin policy, so it is always possible to switch into child browsing contexts, even if they are different origin to the current browsing context. WebDriver is not bound by the same origin policy, so it is always possible to switch into child browsing contexts, even if they are different origin to the current browsing context.

11.7 11.7 Switch To Parent Frame Switch To Parent Frame HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/frame/parent

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. Run the substeps if the current browsing context is already the top-level browsing context : Run the substeps if the current browsing context is already the top-level browsing context :

  2. If the current browsing context is no longer open , return error with If session's current parent browsing context is no longer open , return error code no such window . Return success with data null . with error code no such window . If the current parent browsing context is no longer open , return error with error code no such window .

  3. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  4. If the current If session 's current parent browsing context is not 's current parent browsing context is not null , set the current browsing context with the current parent browsing context . , set the current browsing context with session and current parent browsing context .

  5. Update any implementation-specific state that would result from the user selecting the current browsing context for interaction, without altering OS-level focus. Update any implementation-specific state that would result from the user selecting session 's current browsing context for interaction, without altering OS-level focus.

  6. Return Return success with data with data null . .

11.8 Resizing and positioning windows 11.8 Resizing and positioning windows WebDriver provides commands for interacting with the operating system window containing the current top-level browsing context . Because different operating systems’ window managers provide different abilities, not all of the

WebDriver provides commands in this section can be supported by all remote ends . Support for these for interacting with the operating system window containing session's current top-level browsing context . Because different operating systems’ window managers provide different abilities, not all of the commands in this section can be supported by all remote ends . Support for these commands is determined by the window dimensioning/positioning is determined by the window dimensioning/positioning capability . Where a . Where a command is not supported, an unsupported operation is not supported, an unsupported operation error is returned. is returned.

The top-level browsing context has an associated window state which describes what visibility state its OS widget window is in. It can be in one of the following states: State Keyword Default Description The top-level browsing context has an associated window state which describes what visibility state its OS widget window is in. It can be in one of the following states:

State Keyword Default Description
Maximized window state Maximized window state " maximized " The window is maximized. " The window is maximized.
Minimized window state Minimized window state " minimized " The window is iconified. " The window is iconified.
Normal window state Normal window state " normal " ✓ The window is shown normally. " The window is shown normally.
Fullscreen window state Fullscreen window state " fullscreen " The window is in full screen mode. If for whatever reason the top-level browsing context " The window is in full screen mode.

If for whatever reason the top-level browsing context ’s OS window cannot enter either of the window states , or if this concept is not applicable on the current system, the default state must be ’s OS window cannot enter either of the window states , or if this concept is not applicable on the current system, the default state must be normal . A top-level browsing context .

A top-level browsing context ’s window rect is defined as a dictionary of the ’s window rect is defined as a dictionary of the screenX , , screenY , , outerWidth and and outerHeight attributes of the attributes of the WindowProxy . The WindowRect object for a .

The WindowRect object for a WindowProxy , , window is a is a object initalised with the following properties: initalised with the following properties:

" x " "

window ’s ’s screenX attribute. attribute.

" y " "

window ’s ’s screenY attribute. attribute.

" width " "

windows ’s ’s outerWidth attribute. attribute.

" height " "

window ’s ’s outerHeight attribute.

To maximize the window , given an operating system level window with an associated top-level browsing context , run the implementation-specific steps to transition the operating system level window into the maximized window state . If the window manager supports window resizing but does not have a concept of window maximization, the window dimensions must be increased to the maximum available size permitted by the window manager for the current screen. Return when the window has completed the transition, or within an implementation-defined timeout.

To iconify the window , given an operating system level window with an associated top-level browsing context , run implementation-specific steps to iconify, minimize, or hide the window from the visible screen. Do not return from this operation until the visibility state of the top-level browsing context attribute. To maximize the window , given an operating system level window with an associated top-level browsing context , run the implementation-specific steps to transition the operating system level window into the maximized window state . If the window manager supports window resizing but does not have a concept of window maximization, the window dimensions must be increased to the maximum available size permitted by the window manager for the current screen. Return when the window has completed the transition, or within an implementation-defined timeout. To iconify the window , given an operating system level window with an associated top-level browsing context , run implementation-specific steps to iconify, minimize, or hide the window from the visible screen. Do not return from this operation until the visibility state of the top-level browsing context ’s active document has reached the ’s active document has reached the hidden state, or until the operation times out.

To restore the window , given an operating system level window with an associated top-level browsing context , run implementation-specific steps to restore or unhide the window to the visible screen. Do not return from this operation until the visibility state of the top-level browsing context state, or until the operation times out. To restore the window , given an operating system level window with an associated top-level browsing context , run implementation-specific steps to restore or unhide the window to the visible screen. Do not return from this operation until the visibility state of the top-level browsing context ’s active document has reached the ’s active document has reached the visible state, or until the operation times out. state, or until the operation times out.

11.8.1 11.8.1 Get Window Rect Get Window Rect HTTP Method URI Template

HTTP Method URI Template
GET /session/{session id}/window/rect /session/{session id}/window/rect
Note

The Get Window Rect The Get Window Rect command returns the size and position on the screen of the operating system window corresponding to the current top-level browsing context . returns the size and position on the screen of the operating system window corresponding to session's current top-level browsing context .

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Return Return success with data set to the WindowRect object for the current top-level browsing context . with data set to the WindowRect object for the session's current top-level browsing context .

11.8.2 11.8.2 Set Window Rect Set Window Rect HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/window/rect

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. Let Let width be the result of getting a property named be the result of getting a property named " width from the " from parameters argument, else let it be , else let it be null . .

  2. Let Let height be the result of getting a property named be the result of getting a property named " height from the " from parameters argument, else let it be , else let it be null . .

  3. Let Let x be the result of getting a property named be the result of getting a property named " x from the " from parameters argument, else let it be , else let it be null . .

  4. Let Let y be the result of getting a property named be the result of getting a property named " y from the " from parameters argument, else let it be , else let it be null . .

  5. If If width or or height is neither is neither null nor a nor a Number from 0 to 2 from 0 to 2 31 − 1, return error with − 1, return error code invalid argument . with error code invalid argument .

  6. If If x or or y is neither is neither null nor a nor a Number from −(2 from −(2 31 ) to 2 ) to 2 31 − 1, return error with − 1, return error code invalid argument . with error code invalid argument .

  7. If the remote end does not support the Set Window Rect If the remote end does not support the Set Window Rect command for the current top-level browsing context for any reason, return error with for session's current top-level browsing context for any reason, return error code unsupported operation . with error code unsupported operation .

  8. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

  9. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  10. Fully exit fullscreen . Fully exit fullscreen .

  11. Restore the window . Restore the window .

  12. If If width and and height are not are not null : :

    1. Set the width, in CSS pixels , of the operating system window containing the current top-level browsing context , including any browser chrome and externally drawn window decorations to a value that is as close as possible to Set the width, in CSS pixels , of the operating system window containing session's current top-level browsing context , including any browser chrome and externally drawn window decorations to a value that is as close as possible to width . .

    2. Set the height, in CSS pixels , of the operating system window containing the current top-level browsing context , including any browser chrome and externally drawn window decorations to a value that is as close as possible to Set the height, in CSS pixels , of the operating system window containing session's current top-level browsing context , including any browser chrome and externally drawn window decorations to a value that is as close as possible to height . .

      Note
      The specification does not guarantee that the resulting window size will exactly match that which was requested. In particular the implementation is expected to clamp values that are larger than the physical screen dimensions, or smaller than the minimum window size. Particular implementations may have other limitations such as not being able to resize in single-pixel increments. This is intended to mutate the value of the current top-level browsing context
  13. If If x and and y are not are not null : :

    1. Run the implementation-specific steps to set the position of the operating system level window containing the current top-level browsing context to the position given by the Run the implementation-specific steps to set the position of the operating system level window containing session's current top-level browsing context to the position given by the x and and y coordinates. coordinates.

      Note
      Note that this step is similar to calling the moveTo(x, y) method on the
  14. Return Return success with data set to the WindowRect object for the current top-level browsing context . with data set to the WindowRect object for the session's current top-level browsing context .

11.8.3 11.8.3 Maximize Window Maximize Window HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/window/maximize
Note

The Maximize Window command invokes the window manager-specific “maximize” operation, if any, on the window containing the current top-level browsing context . This typically increases the window to the maximum available size without going full-screen. The Maximize Window command invokes the window manager-specific “maximize” operation, if any, on the window containing session's current top-level browsing context . This typically increases the window to the maximum available size without going full-screen.

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. If the remote end does not support the Maximize Window command for the current top-level browsing context for any reason, return error with If the remote end does not support the Maximize Window command for session's current top-level browsing context for any reason, return error code unsupported operation . with error code unsupported operation .

  2. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

  3. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  4. Fully exit fullscreen . Fully exit fullscreen .

  5. Restore the window . Restore the window .

  6. Maximize the window of the current top-level browsing context . Maximize the window of session's current top-level browsing context .

  7. Return Return success with data set to the WindowRect object for the current top-level browsing context . with data set to the WindowRect object for the session's current top-level browsing context .

11.8.4 11.8.4 Minimize Window Minimize Window HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/window/minimize
Note

The Minimize Window command invokes the window manager-specific “minimize” operation, if any, on the window containing the current top-level browsing context . This typically hides the window in the system tray. The Minimize Window command invokes the window manager-specific “minimize” operation, if any, on the window containing session's current top-level browsing context . This typically hides the window in the system tray.

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. If the remote end does not support the Minimize Window command for the current top-level browsing context for any reason, return error with If the remote end does not support the Minimize Window command for session's current top-level browsing context for any reason, return error code unsupported operation . with error code unsupported operation .

  2. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

  3. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  4. Fully exit fullscreen . Fully exit fullscreen .

  5. Iconify the window . Iconify the window .

  6. Return Return success with data set to the WindowRect object for the current top-level browsing context . with data set to the WindowRect object for the session's current top-level browsing context .

11.8.5 11.8.5 Fullscreen Window Fullscreen Window HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/window/fullscreen The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the remote end does not support fullscreen return error with If the remote end does not support fullscreen return error code unsupported operation . with error code unsupported operation .

  2. If the current top-level browsing context is no longer open , return error with If session's current top-level browsing context is no longer open , return error code no such window . with error code no such window .

  3. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  4. Restore the window . Restore the window .

  5. Call fullscreen an element with the current top-level browsing context Call fullscreen an element with session's current top-level browsing context ’s active document ’s active document ’s document element . ’s document element .

  6. Return Return success with data set to the WindowRect object for the current top-level browsing context . with data set to the WindowRect object for the session's current top-level browsing context .

12. 12. Elements A web element is an abstraction used to identify an

A web element is an abstraction used to identify an element when it is transported via the when it is transported via the protocol , between , between remote - and - and local ends. The web element identifier is the string constant " ends.

The web element identifier is the string constant " element-6066-11e4-a52e-4f735466cecf ". Each element has an associated web element reference that uniquely identifies the ".

Each element across all browsing contexts . The web has an associated web element reference that uniquely identifies the element reference for every across all browsing contexts . The web element reference for every element representing the same representing the same element must be the same. It must be a string, and should be the result of generating a UUID . An ECMAScript must be the same. It must be a string, and should be the result of generating a UUID .

An ECMAScript Object represents a web element if it has a web element identifier own property . Each browsing context has an associated list of known elements . When the browsing context is discarded , the list of known elements is represents a web element if it has a web element identifier own property .

Each browsing context has an associated list of known elements . When the browsing context is discarded along with it. To get a known element with argument , the list of known elements is discarded along with it.

To get a known element with argument reference , run the following steps: Let element be the item in the current browsing context ’s list of known elements for which the web , run the following steps:

  1. Let element reference be the item in the current browsing context is equal to ’s list of known elements for which the web element reference is equal to reference , if such an element exists. Otherwise return error with , if such an element exists. Otherwise return error code no such element . If with error code no such element .
  2. If element is stale , return error with is stale , return error code stale element reference . Return with error code stale element reference .
  3. Return success with element . To get a known connected with element with argument .

To get a known connected element with argument reference , run the following steps: Let , run the following steps:

  1. Let element be the result of be the result of trying to get a known element with argument to get a known element with argument reference . If .
  2. If element is not is not connected return error with return error code stale element reference . Return with error code stale element reference .
  3. Return success with element . To get or create a web with element reference with .

To get or create a web element reference with element : :

  1. For each known element For each known element of session of the current browsing context 's current browsing context ’s list of known elements : ’s list of known elements :

    1. If known element If known element equals element , return , return success with known element with known element ’s web element reference . ’s web element reference .

  2. Add Add element to the list of known elements of session to the list of known elements of the current browsing context . 's current browsing context .

  3. Return Return success with the with the element ’s web element reference . The web element reference object for ’s web element reference .

The web element reference object for element is given by: is given by:

  1. Let identifier be the web element Let identifier . be the web element identifier .

  2. Let reference be the result of get or create a web element Let reference given be the result of get or create a web element reference given element . .

  3. Return a JSON Return a JSON Object initialized with a property with name initialized with a property with name identifier and value and value reference . When required to deserialize a web element by a JSON .

When required to deserialize a web element by a JSON Object object that represents a web element : that represents a web element :

  1. If If object has no own property web element identifier , return error with has no own property web element identifier , return error code invalid argument . with error code invalid argument .

  2. Let Let reference be the result of be the result of getting the web element identifier property from the web element identifier property from object . .

  3. Let Let element be the result of be the result of trying to get a known element with argument to get a known element with argument reference . .

  4. Return Return success with data with data element . An .

An element is stale if its node document is not the active document or if it is not is stale if its node document is not the active document or if it is not connected . To scroll into view an .

To scroll into view an element perform the following steps only if the element is not already in view : perform the following steps only if the element is not already in view :

  1. Let Let options be the following be the following ScrollIntoViewOptions : :

    Logical scroll position " Logical scroll position " block "
    " end " "
    Logical scroll position " Logical scroll position " inline "
    " nearest " "
  2. On the On the element , , Call ( scrollIntoView , , options ). ).

Editable elements are those that can be used for are those that can be used for typing and and clearing , and they fall into two subcategories: , and they fall into two subcategories:

Mutable form control elements Mutable form control elements

Denotes Denotes input elements that are elements that are mutable (e.g. that are not read only or (e.g. that are not read only or disabled ) and whose ) and whose type attribute is in one of the following states: attribute is in one of the following states:

And the textarea element. element.

Mutable elements Mutable elements

Denotes elements that are editing hosts or content editable . An Denotes elements that are editing hosts or content editable .

An element is said to have pointer events disabled if the resolved value of its " is said to have pointer events disabled if the resolved value of its " pointer-events " style property is " " style property is " none ". An ".

An element is to be considered read only if it is an is to be considered read only if it is an input element whose element whose readOnly attribute is set. attribute is set.

12.1 12.1 Interactability In order to determine if an element can be interacted with using pointer actions, WebDriver performs hit-testing to find if the interaction will be able to reach the requested element. An interactable

In order to determine if an element is an can be interacted with using pointer actions, WebDriver performs hit-testing to find if the interaction will be able to reach the requested element.

An interactable element is an element which is either which is either pointer-interactable or or keyboard-interactable . A pointer-interactable element is defined to be the first .

A pointer-interactable element is defined to be the first element , defined by the paint order found at the center point of its rectangle that is inside the , defined by the paint order found at the center point of its rectangle that is inside the viewport , excluding the size of any rendered scrollbars. A keyboard-interactable element is any , excluding the size of any rendered scrollbars.

A keyboard-interactable element is any element that has a focusable area , is a that has a focusable area , is a body element , or is the document element . An element , or is the document element .

An element ’s in-view center point is the origin position of the rectangle that is the intersection between the element’s first ’s in-view center point is the origin position of the rectangle that is the intersection between the element’s first DOMRect of of getClientRects () and the initial viewport . Given an and the initial viewport . Given an element that is known to be in view , it can be calculated this way: that is known to be in view , it can be calculated this way:

  1. Let Let rectangle be the first be the first element of the of the DOMRect sequence returned by calling sequence returned by calling getClientRects () on on element . .

  2. Let Let left be be max (0, (0, min ( x coordinate , x coordinate + width dimension x coordinate , x coordinate + width dimension )). )).

  3. Let Let right be be min ( innerWidth , , max ( x coordinate , x coordinate + width dimension x coordinate , x coordinate + width dimension )). )).

  4. Let Let top be be max (0, (0, min ( y coordinate , y coordinate + height dimension y coordinate , y coordinate + height dimension )). )).

  5. Let Let bottom be be min ( innerHeight , , max ( y coordinate , y coordinate + height dimension y coordinate , y coordinate + height dimension )). )).

  6. Let Let x be be floor (( left + + right ) ÷ 2.0). ) ÷ 2.0).

  7. Let Let y be be floor (( top + + bottom ) ÷ 2.0). ) ÷ 2.0).

  8. Return the pair of ( Return the pair of ( x , , y ). An ).

An element is in view if it is a member of its own pointer-interactable paint tree , given the pretense that its pointer events are not disabled . An is in view if it is a member of its own pointer-interactable paint tree , given the pretense that its pointer events are not disabled .

An element is is obscured if the pointer-interactable paint tree at its center point is empty, or the first element in this tree is not an inclusive descendant of itself. if the pointer-interactable paint tree at its center point is empty, or the first element in this tree is not an inclusive descendant of itself.

An element ’s pointer-interactable paint tree is produced this way: ’s pointer-interactable paint tree is produced this way:

  1. If If element is not in the same tree as session is not in the same tree as the current browsing context 's current browsing context ’s active document , return an empty sequence. ’s active document , return an empty sequence.

  2. Let Let rectangles be the be the DOMRect sequence returned by calling sequence returned by calling getClientRects () . .

  3. If If rectangles has the length of 0, return an empty sequence. has the length of 0, return an empty sequence.

  4. Let center point be the in-view center point of the first indexed element in Let center point be the in-view center point of the first indexed element in rectangles . .

  5. Return the elements from point given the coordinates center point . Return the elements from point given the coordinates center point .

12.2 Shadow Roots 12.2 Shadow Roots A shadow root is an abstraction used to identify a shadow root when it is transported via the

A shadow root is an abstraction used to identify a shadow root when it is transported via the protocol , between , between remote and and local ends. The shadow root identifier is the string constant " ends.

The shadow root identifier is the string constant " shadow-6066-11e4-a52e-4f735466cecf ". Each shadow root has an associated shadow root reference that uniquely identifies the shadow root across all browsing contexts . The shadow root reference for every shadow root representing the same shadow root must be the same. It must be a string, and should be the result of generating a UUID . An ECMAScript ".

Each shadow root has an associated shadow root reference that uniquely identifies the shadow root across all browsing contexts . The shadow root reference for every shadow root representing the same shadow root must be the same. It must be a string, and should be the result of generating a UUID .

An ECMAScript Object represents a shadow root if it has a shadow root identifier own property . Each browsing context has an associated list of known shadow roots . When the browsing context is discarded , the list of known shadow roots is represents a shadow root if it has a shadow root identifier own property .

Each browsing context has an associated list of known shadow roots . When the browsing context is discarded along with it. To get a known shadow root with argument , the list of known shadow roots is discarded along with it.

To get a known shadow root with argument reference , run the following steps: Let shadow be the item in the current browsing context ’s list of known shadow roots for which the , run the following steps:

  1. Let shadow root reference be the item in the current browsing context is equal to ’s list of known shadow roots for which the shadow root reference is equal to reference , if such a shadow root exists. Otherwise return error with , if such a shadow root exists. Otherwise return error code no such element . If with error code no such element .
  2. If shadow is detached , return error with is detached , return error code detached shadow root . Return with error code detached shadow root .
  3. Return success with shadow . To get or create a with shadow root reference with .

To get or create a shadow root reference with shadow root shadow root : :

  1. For each known shadow root of the current browsing context For each known shadow root of the current browsing context ’s list of known shadow roots : ’s list of known shadow roots :

    1. If known shadow root If known shadow root equals shadow root , return shadow root , return success with known shadow root with known shadow root ’s shadow root reference . ’s shadow root reference .

  2. Add shadow to the list of known Add shadow roots of the current browsing context . to the list of known shadow roots of the current browsing context .

  3. Return Return success with the shadow ’s shadow root reference . The shadow root reference object for with the shadow root is given by: ’s shadow root reference .

The shadow root reference object for shadow root is given by:

  1. Let identifier be the shadow root Let identifier . be the shadow root identifier .

  2. Let reference be the result of get or create a shadow root Let reference given shadow root . be the result of get or create a shadow root reference given shadow root .

  3. Return a JSON Return a JSON Object initialized with a property with name initialized with a property with name identifier and value and value reference . When required to deserialize a shadow root by a JSON .

When required to deserialize a shadow root by a JSON Object object that represents a shadow root : that represents a shadow root :

  1. If If object has no own property shadow root identifier , return error with has no own property shadow root identifier , return error code invalid argument . with error code invalid argument .

  2. Let Let reference be the result of be the result of getting the shadow root identifier property from the shadow root identifier property from object . .

  3. Let Let shadow be the result of be the result of trying to get a known shadow root with argument to get a known shadow root with argument reference . .

  4. Return Return success with data shadow . A with data shadow root is detached if its node document is not the active document or if the element node referred to as its document fragment host is stale . .

A shadow root is detached if its node document is not the active document or if the element node referred to as its document fragment host is stale .

12.3 12.3 Retrieval The Find Element , Find Elements , Find Element From Element , Find Elements From Element , Find Element From Shadow Root , and Find Elements From Shadow Root

The Find Element , Find Elements , Find Element From Element , Find Elements From Element , Find Element From Shadow Root , and Find Elements From Shadow Root commands allow lookup of individual elements and collections of elements. Element retrieval searches are performed using pre-order traversal of the document’s nodes that match the provided selector’s expression. When required to allow lookup of individual elements and collections of elements. Element retrieval searches are performed using pre-order traversal of the document’s nodes that match the provided selector’s expression.

When required to find with arguments start node , with arguments start node , using and and value , a remote end must run the following steps: , a remote end must run the following steps:

  1. Let end time be the current time plus the session implicit wait timeout . Let end time be the current time plus the session implicit wait timeout .

  2. Let location strategy be equal to Let location strategy be equal to using . .

  3. Let Let selector be equal to be equal to value . .

  4. Let elements returned be the result of Let elements returned be the result of trying to call the relevant element location strategy with arguments start node , and to call the relevant element location strategy with arguments start node , and selector . If a .

  5. If a DOMException , , SyntaxError , , XPathException , or other error occurs during the execution of the element location strategy , return , or other error occurs during the execution of the element location strategy , return error invalid selector . invalid selector .
  6. If elements returned is empty and the current time is less than end time return to step 4. Otherwise, continue to the next step. If elements returned is empty and the current time is less than end time return to step 4. Otherwise, continue to the next step.

  7. Let Let result be an empty JSON be an empty JSON List . .

  8. For each element in elements returned , append the web For each element reference object for in elements returned , append the web element reference object for element , to , to result . .

  9. Return Return success with data with data result . .

12.3.1 Locator strategies 12.3.1 Locator strategies An element location strategy is an enumerated attribute deciding what technique should be used to search for

An element location strategy is an enumerated attribute deciding what technique should be used to search for elements in the current browsing context . The following table of location strategies lists the keywords and states defined for this attribute: State Keyword in session 's current browsing context . The following table of location strategies lists the keywords and states defined for this attribute:

State Keyword
CSS selector CSS selector " css selector css selector " "
Link text selector Link text selector " link text link text " "
Partial link text selector Partial link text selector " partial link text partial link text " "
Tag name Tag name " tag name tag name " "
XPath selector XPath selector " xpath " "
12.3.1.1 CSS selectors 12.3.1.1 CSS selectors To find a web element with the CSS Selector

To find a web element with the CSS Selector strategy the following steps need to be completed: the following steps need to be completed:

  1. Let Let elements be the result of calling be the result of calling querySelectorAll () with start node as with start node as this and and selector as the argument. If this causes an exception to be thrown, return error with as the argument. If this causes an exception to be thrown, return error code invalid selector . with error code invalid selector .

  2. Return Return success with data with data elements . .

12.3.1.4 Tag name 12.3.1.4 Tag name To find a web element with the Tag Name

To find a web element with the Tag Name strategy return return success with data set to the result of calling with data set to the result of calling getElementsByTagName with start node as with start node as this and and selector as the argument. as the argument.

12.3.1.5 12.3.1.5 XPath To find a web element with the XPath Selector

To find a web element with the XPath Selector strategy the following steps need to be completed: the following steps need to be completed:

  1. Let Let evaluateResult be the result of calling be the result of calling evaluate , with arguments , with arguments selector , start node , , start node , null , , ORDERED_NODE_SNAPSHOT_TYPE , and , and null . .

    Note

    A snapshot is used to promote operation atomicity. A snapshot is used to promote operation atomicity.

  2. Let Let index be 0. be 0.

  3. Let Let length be the result of getting the property " be the result of getting the property " snapshotLength " from " from evaluateResult . If this throws an . If this throws an XPathException return error with error code invalid selector , otherwise if this throws any other exception return error with return error code unknown with error code invalid selector , otherwise if this throws any other exception return error . with error code unknown error .

  4. Let Let result be an empty be an empty NodeList . .

  5. Repeat, while Repeat, while index is less than is less than length : Let :

    1. Let node be the result of calling be the result of calling snapshotItem with with evaluateResult as as this and and index as the argument. as the argument.
    2. If If node is not an is not an element return an error with return an error code invalid selector . Append with error code invalid selector .

    3. Append node to to result . Increment .
    4. Increment index by 1. by 1.
  6. Return Return success with data with data result . .

12.3.2 12.3.2 Find Element Find Element HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/element
Note
The Find Element The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. Let location strategy be the result of getting a property called " Let location strategy be the result of getting a property named " using ". " from parameters .

  2. If location strategy is not present as a keyword in the table of location strategies , return error with If location strategy is not present as a keyword in the table of location strategies , return error code invalid argument . with error code invalid argument .

  3. Let Let selector be the result of getting a property called " be the result of getting a property named " value ". " from parameters .

  4. If If selector is is undefined , return error with , return error code invalid argument . with error code invalid argument .

  5. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  6. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  7. Let start node Let start node be session be the current browsing context 's current browsing context ’s document element . ’s document element .

  8. If start node is If start node is null , return error with , return error code no such element . with error code no such element .

  9. Let result be the Let result of be the result of trying to to Find with start node , location strategy , and with start node , location strategy , and selector . .

  10. If If result is empty, return error with is empty, return error code no such element . Otherwise, return the first element of with error code no such element . Otherwise, return the first element of result . .

12.3.3 12.3.3 Find Elements Find Elements HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/elements The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. Let location strategy be the result of getting a property called " Let location strategy be the result of getting a property named " using ". " from parameters .

  2. If location strategy is not present as a keyword in the table of location strategies , return error with If location strategy is not present as a keyword in the table of location strategies , return error code invalid argument . with error code invalid argument .

  3. Let Let selector be the result of getting a property called " be the result of getting a property named " value ". " from parameters .

  4. If If selector is is undefined , return error with , return error code invalid argument . with error code invalid argument .

  5. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  6. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  7. Let start node Let start node be session be the current browsing context 's current browsing context ’s document element . ’s document element .

  8. If start node is If start node is null , return error with , return error code no such element . Return the result of with error code no such element .

  9. Return the result of trying to to Find with start node , location strategy , and with start node , location strategy , and selector . .

12.3.4 12.3.4 Find Element From Element Find Element From Element HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/element/{ element id element id }/element The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. Let location strategy be the result of getting a property called " Let location strategy be the result of getting a property named " using ". " from parameters .

  2. If location strategy is not present as a keyword in the table of location strategies , return error with If location strategy is not present as a keyword in the table of location strategies , return error code invalid argument . with error code invalid argument .

  3. Let Let selector be the result of getting a property called " be the result of getting a property named " value ". " from parameters .

  4. If If selector is is undefined , return error with , return error code invalid argument . with error code invalid argument .

  5. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  6. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  7. Let element id be URL variables ' element id.
  8. Let start node be the result of Let start node be the result of trying to get a known connected element with url variable element id . Let result to get a known connected element with URL variables be the value of ' element id.

  9. Let result be the value of trying to to Find with start node , location strategy , and with start node , location strategy , and selector . .
  10. If If result is empty, return error with is empty, return error code no such element . Otherwise, return the first element of with error code no such element . Otherwise, return the first element of result . .

12.3.5 12.3.5 Find Elements From Element Find Elements From Element HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/element/{ element id element id }/elements The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. Let location strategy be the result of getting a property called " Let location strategy be the result of getting a property named " using ". " from parameters .

  2. If location strategy is not present as a keyword in the table of location strategies , return error with If location strategy is not present as a keyword in the table of location strategies , return error code invalid argument . with error code invalid argument .

  3. Let Let selector be the result of getting a property called " be the result of getting a property named " value ". " from parameters .

  4. If If selector is is undefined , return error with , return error code invalid argument . with error code invalid argument .

  5. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  6. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  7. Let start node be the result of Let start node be the result of trying to get a known connected element with url variable element id . Return the result of to get a known connected element with URL variables ' element id.

  8. Return the result of trying to to Find with start node , location strategy , and with start node , location strategy , and selector . .

12.3.6 12.3.6 Find Element From Shadow Root Find Element From Shadow Root HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/shadow/{ shadow id shadow id }/element The remote end steps are:

The remote end steps are:

  1. Let location strategy be the result of getting a property called " Let location strategy be the result of getting a property called " using ". ".

  2. If location strategy is not present as a keyword in the table of location strategies , return error with If location strategy is not present as a keyword in the table of location strategies , return error code invalid argument . with error code invalid argument .

  3. Let Let selector be the result of getting a property called " be the result of getting a property called " value ". ".

  4. If If selector is is undefined , return error with , return error code invalid argument . with error code invalid argument .

  5. If the current browsing context is no longer open , return error with If the current browsing context is no longer open , return error code no such window . with error code no such window .

  6. Handle any user prompts and return its value if it is an Handle any user prompts and return its value if it is an error . .

  7. Let start node be the result of Let start node be the result of trying to get a known shadow root with url variable shadow id . Let to get a known shadow root with url variable shadow id .

  8. Let result be the value of be the value of trying to to Find with start node , location strategy , and with start node , location strategy , and selector . .
  9. If If result is empty, return error with is empty, return error code no such element . Otherwise, return the first element of with error code no such element . Otherwise, return the first element of result . .

12.3.7 12.3.7 Find Elements From Shadow Root Find Elements From Shadow Root HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/shadow/{ shadow id shadow id }/elements The remote end steps are:

The remote end steps are:

  1. Let location strategy be the result of getting a property called " Let location strategy be the result of getting a property called " using ". ".

  2. If location strategy is not present as a keyword in the table of location strategies , return error with If location strategy is not present as a keyword in the table of location strategies , return error code invalid argument . with error code invalid argument .

  3. Let Let selector be the result of getting a property called " be the result of getting a property called " value ". ".

  4. If If selector is is undefined , return error with , return error code invalid argument . with error code invalid argument .

  5. If the current browsing context is no longer open , return error with If the current browsing context is no longer open , return error code no such window . with error code no such window .

  6. Handle any user prompts and return its value if it is an Handle any user prompts and return its value if it is an error . .

  7. Let start node be the result of Let start node be the result of trying to get a known shadow root with url variable shadow id . Return the result of to get a known shadow root with url variable shadow id .

  8. Return the result of trying to to Find with start node , location strategy , and with start node , location strategy , and selector . .

12.3.8 12.3.8 Get Active Element Get Active Element HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/active The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let active element Let active element be the active element of session be the active element of the current browsing context 's current browsing context ’s document element . ’s document element .

  4. If active element is a non-null If active element is a non-null element , return , return success with data set to web element reference object for active element . Otherwise, return error with with data set to web element reference object for active element .

    Otherwise, return error code no such element . with error code no such element .

12.3.9 12.3.9 Get Element Shadow Root Get Element Shadow Root HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/shadow The remote end steps are:

The remote end steps are:

  1. If the current browsing context is no longer open , return error with If the current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an Handle any user prompts and return its value if it is an error . .

  3. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with url variable element id .

  4. Let shadow root be Let shadow root be element 's shadow root . 's shadow root .

  5. If shadow root is null, return error with If shadow root is null, return error code no such shadow root . with error code no such shadow root .

  6. Let serialized be the shadow root reference object for shadow root . Let serialized be the shadow root reference object for shadow root .

  7. Return Return success with data with data serialized . .

12.4 12.4 State To calculate the absolute position of

To calculate the absolute position of element : :

  1. Let Let rect be the value returned by calling be the value returned by calling getBoundingClientRect () . .

  2. Let window be the associated Let window of current top-level browsing context . be the associated window of current top-level browsing context .

  3. Let Let x be ( be ( scrollX of of window + + rect ’s x coordinate ’s x coordinate ). ).

  4. Let Let y be ( be ( scrollY of of window + + rect ’s y coordinate ’s y coordinate ). ).

  5. Return a pair of ( Return a pair of ( x , , y ). To determine if ).

To determine if node is not in the same tree as another is not in the same tree as another node , , other , run the following substeps: , run the following substeps:

  1. If the node ’s If the node document is not ’s node document is not other ’s node document , return true. ’s node document , return true.

  2. Return true if the result of calling the Return true if the result of calling the node ’s ’s compareDocumentPosition with with other as argument is as argument is DOCUMENT_POSITION_DISCONNECTED (1), otherwise return false. An (1), otherwise return false.

An element ’s ’s container is: option element in a valid element context is:

option element in a valid element context
optgroup element in a valid element context element in a valid element context

The The element ’s element context , which is determined by: ’s element context , which is determined by:

  1. Let datalist parent be the first Let datalist parent be the first datalist element reached by traversing the tree in reverse order from element reached by traversing the tree in reverse order from element , or , or undefined if the root of the tree is reached. if the root of the tree is reached.

  2. Let select parent be the first Let select parent be the first select element reached by traversing the tree in reverse order from element reached by traversing the tree in reverse order from element , or , or undefined if the root of the tree is reached. if the root of the tree is reached.

  3. If datalist parent is If datalist parent is undefined , the element context is select parent . Otherwise, the element context is datalist parent . , the element context is select parent . Otherwise, the element context is datalist parent .

option element in an invalid element context element in an invalid element context

The element does not have a container. Otherwise The element does not have a container.

Otherwise

The container is the The container is the element itself. itself.

12.4.1 12.4.1 Is Element Selected Is Element Selected HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/selected
Note
The Is Element Selected

The Is Element Selected command determines if the referenced determines if the referenced element is selected or not. This operation only makes sense on is selected or not. This operation only makes sense on input elements of the elements of the Checkbox - and Radio Button states, or on - and Radio Button states, or on option elements . elements .

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with URL variables ' element id.

  4. Let Let selected be the value corresponding to the first matching statement: be the value corresponding to the first matching statement:

    element is an is an input element with a element with a type attribute in the attribute in the Checkbox - or Radio Button state - or Radio Button state

    The result of The result of element ’s ’s checkedness . .

    element is an is an option element element

    The result of The result of element ’s ’s selectedness . Otherwise False. .

    Otherwise
    False.
  5. Return Return success with data with data selected . .

12.4.2 12.4.2 Get Element Attribute Get Element Attribute HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/attribute/{ name } The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known element with url variable element id . Let result to get a known element with URL variables be the result of the first matching condition: If ' element id.

  4. Let name be URL variables is a boolean attribute ' name.

  5. Let result be the result of the first matching condition:
    If name is a boolean attribute

    " true " (string) if the " (string) if the element has the attribute , otherwise has the attribute , otherwise null . Otherwise .

    Otherwise

    The result of getting an attribute by name The result of getting an attribute by name name . .

  6. Return Return success with data with data result . .

Note

Please note that the behavior of this command deviates from the behavior of Please note that the behavior of this command deviates from the behavior of getAttribute in [ in [ DOM ], which in the case of a set boolean attribute would return an empty string. The reason this command returns true as a string is because this evaluates to true in most dynamically typed programming languages, but still preserves the expected type information. ], which in the case of a set boolean attribute would return an empty string. The reason this command returns true as a string is because this evaluates to true in most dynamically typed programming languages, but still preserves the expected type information.

12.4.3 12.4.3 Get Element Property Get Element Property HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/property/{ name } The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known element with url variable element id . to get a known element with URL variables ' element id.

  4. Let property Let name URL variables be the result of calling the ' name.

  5. Let property be the result of calling the element . [[GetProperty]] ( name ). ).

  6. Let Let result be the value of be the value of property if not if not undefined , or , or null . .

  7. Return Return success with data with data result . .

12.4.4 12.4.4 Get Element CSS Value Get Element CSS Value HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/css/{ property name property name } The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with URL variables ' element id .

  4. Let computed value be the result of the first matching condition: Let computed value be the result of the first matching condition:

    current browsing context current browsing context ’s ’s document type is not " is not " xml " "
    computed value of parameter property name from computed value of parameter property name from element ’s style declarations. property name is obtained from url variables . Otherwise "" (empty string) Return ’s style declarations. property name is obtained from URL variables .
    Otherwise
    "" (empty string)
  5. Return success with data computed value . with data computed value .

12.4.5 12.4.5 Get Element Text Get Element Text HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/text
Note
The Get Element Text When processing text,

When processing text, whitespace is defined as characters from the Unicode Character Database with the Unicode character property " is defined as characters from the Unicode Character Database with the Unicode character property " WSpace=Y " or " " or " WS ". [ ". [ UAX44 ] The remote end steps are: ]

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with URL variables ' element id.

  4. Let rendered text be the result of performing implementation-specific steps whose result is exactly the same as the result of a Let rendered text be the result of performing implementation-specific steps whose result is exactly the same as the result of a Call ( bot.dom.getVisibleText , , null , , element ). ).

  5. Return Return success with data rendered text . with data rendered text .

12.4.6 12.4.6 Get Element Tag Name Get Element Tag Name HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/name The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known element with url variable element id . to get a known element with URL variables ' element id .

  4. Let qualified name be the result of getting Let qualified name be the result of getting element ’s ’s tagName content content attribute . .

  5. Return Return success with data qualified name . with data qualified name .

12.4.7 12.4.7 Get Element Rect Get Element Rect HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/rect
Note
The Get Element Rect The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with URL variables ' element id.

  4. Calculate the absolute position of Calculate the absolute position of element and let it be and let it be coordinates . .

  5. Let Let rect be be element ’s bounding rectangle . ’s bounding rectangle .

  6. Let Let body be a new JSON be a new JSON Object initialized with: initialized with:

    " x " The first value of "
    The first value of coordinates . .
    " y " The second value of "
    The second value of coordinates . .
    " width " Value of "
    Value of rect ’s width dimension . ’s width dimension .
    " height " Value of "
    Value of rect ’s height dimension . ’s height dimension .
  7. Return Return success with data with data body . .

12.4.8 12.4.8 Is Element Enabled Is Element Enabled HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/enabled The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with URL variables ' element id.

  4. Let Let enabled be a boolean initially set to true if session be a boolean initially set to true if the current browsing context 's current browsing context ’s ’s document type is not " is not " xml ". Otherwise, let ".

    Otherwise, let enabled to false and jump to the last step of this algorithm. to false and jump to the last step of this algorithm.

  5. Set Set enabled to false if a form control is to false if a form control is disabled . .

  6. Return Return success with data with data enabled . .

12.4.9 12.4.9 Get Computed Role Get Computed Role HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/computedrole The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with URL variables ' element id.

  4. Let role be the result of computing the WAI-ARIA Let role of be the result of computing the WAI-ARIA role of element . .

  5. Return Return success with data with data role . .

12.4.10 12.4.10 Get Computed Label Get Computed Label HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/element/{ element id element id }/computedlabel The remote end steps are: If the current browsing context is no longer open , return error with

The remote end steps , given session , URL variables and parameters are:

  1. If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with URL variables ' element id .

  4. Let Let label be the result of a Accessible Name and Description Computation for the Accessible Name of the be the result of a Accessible Name and Description Computation for the Accessible Name of the element . .

  5. Return Return success with data with data label . .

12.5 12.5 Interaction The

The element interaction interaction commands provide a high-level instruction set for manipulating form controls. Unlike provide a high-level instruction set for manipulating form controls. Unlike Actions , they will implicitly scroll elements into view and check that it is an interactable element . Some resettable elements define their own clear algorithm . Unlike their associated reset algorithms , changes made to form controls as part of these algorithms do count as changes caused by the user (and thus, e.g. , they will implicitly scroll elements into view and check that it is an interactable element .

Some resettable elements define their own clear algorithm . Unlike their associated reset algorithms , changes made to form controls as part of these algorithms do cause count as changes caused by the user (and thus, e.g. do cause input events to fire). When the clear algorithm is invoked for an element that does not define its own clear algorithm , its reset algorithm must be invoked instead. The clear algorithm for events to fire). When the clear algorithm is invoked for an element that does not define its own clear algorithm , its reset algorithm must be invoked instead.

The clear algorithm for input elements is to set the dirty value flag and dirty checkedness flag back to false, set the elements is to set the dirty value flag and dirty checkedness flag back to false, set the value of the element to an empty string, set the of the element to an empty string, set the checkedness of the element to true if the element has a of the element to true if the element has a checked content attribute and false if it does not, empty the list of selected files , and then invoke the value sanitization algorithm iff the content attribute and false if it does not, empty the list of selected files , and then invoke the value sanitization algorithm iff the type attribute’s current state defines one. The clear algorithm for attribute’s current state defines one.

The clear algorithm for textarea elements is to set the dirty value flag back to false, and set the raw value of element to an empty string. The clear algorithm for elements is to set the dirty value flag back to false, and set the raw value of element to an empty string.

The clear algorithm for output elements is set the element’s value mode flag to default and then to set the element’s elements is set the element’s value mode flag to default and then to set the element’s textContent IDL attribute to an empty string (thus clearing the element’s child nodes). IDL attribute to an empty string (thus clearing the element’s child nodes).

12.5.1 12.5.1 Element Click Element Click HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/element/{ element id element id }/click

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with argument element id . to get a known connected element with argument element id .

  4. If the If the element is an is an input element in the file upload state return error with element in the file upload state return error code invalid argument . with error code invalid argument .

  5. Scroll into view the Scroll into view the element ’s ’s container . .

  6. If If element ’s ’s container is still not in view , return error with is still not in view , return error code element not interactable . with error code element not interactable .

  7. If If element ’s ’s container is is obscured by another by another element , return error with , return error code element click intercepted . with error code element click intercepted .

  8. Matching on Matching on element : :

    option element element
    1. Let parent node be the Let parent node be the element ’s ’s container . .

    2. Fire a mouseOver event at parent node . a mouseOver event at parent node .

    3. Fire a mouseMove event at parent node . a mouseMove event at parent node .

    4. Fire a mouseDown event at parent node . a mouseDown event at parent node .

    5. Run the focusing steps on parent node . Run the focusing steps on parent node .

    6. If If element is not is not disabled : :

      1. Fire an an input event at parent node . event at parent node .

      2. Let previous selectedness be equal to Let previous selectedness be equal to element selectedness . .

      3. If If element ’s ’s container has the has the multiple attribute , toggle the attribute , toggle the element ’s ’s selectedness state by setting it to the opposite value of its current state by setting it to the opposite value of its current selectedness . Otherwise, set the .

        Otherwise, set the element ’s ’s selectedness state to true. state to true.

      4. If previous selectedness is false, If previous selectedness is false, fire a a change event at parent node . event at parent node .

    7. Fire a mouseUp event at parent node . a mouseUp event at parent node .

    8. Fire a click event at parent node . Otherwise a click event at parent node .

    Otherwise
    1. Let Let mouse be a new pointer input source . be a new pointer input source .

    2. Let click point be the Let click point be the element ’s in-view center point . ’s in-view center point .

    3. Let pointer move action be an action object with the Let pointer move action be an action object with the mouse ’s ’s id , " , " pointer ", and " ", and " pointerMove " as arguments. " as arguments.

    4. Set a property Set a property x to to 0 on pointer move action . on pointer move action .

    5. Set a property Set a property y to to 0 on pointer move action . on pointer move action .

    6. Set a property Set a property origin to to element on pointer move action . on pointer move action .

    7. Let pointer down action be an action object with the Let pointer down action be an action object with the mouse ’s ’s id , " , " pointer ", and " ", and " pointerDown " as arguments. " as arguments.

    8. Set a property Set a property button to to 0 on pointer down action . on pointer down action .

    9. Let pointer up action be an action object with the Let pointer up action be an action object with the mouse ’s ’s id , " , " mouse ", and " ", and " pointerUp " as arguments. " as arguments.

    10. Set a property Set a property button to to 0 on pointer up action . on pointer up action .

    11. Dispatch a pointerMove action with arguments Dispatch a pointerMove action with session , mouse ’s ’s input id input id , pointer move action , , pointer move action , mouse ’s input source state , and ’s input source state , and 0 . .

    12. Dispatch a pointerDown action with arguments Dispatch a pointerDown action with session , mouse ’s ’s input id input id , pointer down action , , pointer down action , mouse ’s input source state , and ’s input source state , and 0 . .

    13. Dispatch a pointerUp action with arguments Dispatch a pointerUp action with session , mouse ’s ’s input id input id , pointer up action , , pointer up action , mouse ’s input source state , and ’s input source state , and 0 . .

    14. Remove Remove mouse from the current from the session ’s input state table . ’s input state table .

    15. Remove Remove mouse from the list of active input sources . from the list of active input sources .

  9. Wait until the user agent event loop has spun enough times to process the DOM events generated by the previous step. Wait until the user agent event loop has spun enough times to process the DOM events generated by the previous step.

  10. Perform implementation-defined steps to allow any Perform implementation-defined steps to allow any navigations triggered by the click to start. triggered by the click to start.

    Note

    It is not always clear how long this will cause the algorithm to wait, and it is acknowledged that some implementations may have unavoidable race conditions. The intention is to allow a new attempt to It is not always clear how long this will cause the algorithm to wait, and it is acknowledged that some implementations may have unavoidable race conditions. The intention is to allow a new attempt to navigate to begin so that the next step in the algorithm is meaningful. It is possible the click does not cause an attempt to to begin so that the next step in the algorithm is meaningful. It is possible the click does not cause an attempt to navigate , in which case the implementation-defined steps can return immediately, and the next step will also return immediately. , in which case the implementation-defined steps can return immediately, and the next step will also return immediately.

  11. Try to wait for navigation to complete . to wait for navigation to complete .

  12. Try to run the post-navigation checks . to run the post-navigation checks .

  13. Return Return success with data with data null . .

12.5.2 12.5.2 Element Clear Element Clear HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/element/{ element id element id }/clear To clear a content editable element :

To clear a content editable element :

  1. If If element ’s ’s innerHTML IDL attribute is an empty string do nothing and return. IDL attribute is an empty string do nothing and return.

  2. Run the focusing steps for Run the focusing steps for element . .

  3. Set Set element ’s ’s innerHTML IDL attribute to an empty string. IDL attribute to an empty string.

  4. Run the unfocusing steps for the element . To clear a resettable Run the unfocusing steps for the element : .

To clear a resettable element :

  1. Let Let empty be the result of the first matching condition: be the result of the first matching condition:

    element is an is an input element whose element whose type attribute is in the File Upload state True if the list of selected files has a length of 0, and false otherwise. Otherwise True if its attribute is in the File Upload state
    True if the list of selected files has a length of 0, and false otherwise.
    Otherwise
    True if its value IDL attribute is an empty string, and false otherwise. IDL attribute is an empty string, and false otherwise.
  2. If If element is a candidate for constraint validation it satisfies its constraints , and is a candidate for constraint validation it satisfies its constraints , and empty is true, abort these substeps. is true, abort these substeps.

  3. Invoke the focusing steps for Invoke the focusing steps for element . .

  4. Invoke the clear algorithm for Invoke the clear algorithm for element . .

  5. Invoke the unfocusing steps for the Invoke the unfocusing steps for the element . The remote end steps for Element Clear are: .

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let element be the result of be the result of trying to get a known connected element with argument element id . to get a known connected element with argument element id .

  4. If If element is not is not editable , return an error with , return an error code invalid element state . with error code invalid element state .

  5. Scroll into view the Scroll into view the element . .

  6. Wait in an implementation-specific way up to the session implicit wait timeout for Wait in an implementation-specific way up to the session implicit wait timeout for element to become to become interactable . .

  7. If If element is not is not interactable , return error with , return error code element not interactable . with error code element not interactable .

  8. Run the substeps of the first matching statement: Run the substeps of the first matching statement:

    element is a mutable form control element is a mutable form control element

    Invoke the steps to clear a resettable element . Invoke the steps to clear a resettable element .

    element is a mutable element is a mutable element

    Invoke the steps to clear a content editable element . Otherwise Invoke the steps to clear a content editable element .

    Otherwise

    Return error with Return error code invalid element state . with error code invalid element state .

  9. Return Return success with data with data null . .

12.5.3 12.5.3 Element Send Keys Element Send Keys HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/element/{ element id element id }/value
A non-typeable form control is an

A non-typeable form control is an input element whose element whose type attribute state causes the primary input mechanism not to be through means of a keyboard, whether virtual or physical. Non-typeable form controls means to refer to form control elements rendered by the user agent as something other than as a text input control. When targetting an attribute state causes the primary input mechanism not to be through means of a keyboard, whether virtual or physical.

The key input state used for input may be cleared mid-way through “typing” by sending the null key , which is U+E000 (NULL).

When required to clear the modifier key state given session , undo actions and keyboard a remote end must run the following steps: a remote end must run the following steps:

  1. If If keyboard is not a key input source return error with is not a key input source return error code invalid argument . with error code invalid argument .

  2. For each entry key in the lexically sorted keys of undo actions : For each entry key in the lexically sorted keys of undo actions :

    1. Let Let action be the value of undo actions equal to the key entry key . be the value of undo actions equal to the key entry key .

    2. If action is not an If action object of is not an action object of type " " key " and " and subtype " " keyUp ", return error with ", return error code invalid argument . with error code invalid argument .

    3. Dispatch a keyUp action with arguments Dispatch a keyUp action with arguments session , action and and keyboard ’s key input state . An extended grapheme cluster is ’s key input state .

An extended grapheme cluster is typeable if it consists of a single unicode code point and the if it consists of a single unicode code point and the code is not is not undefined . The shifted state for .

The shifted state for keyboard is the value of is the value of keyboard ’s key input state ’s key input state ’s ’s shift property. In order to dispatch the events for a typeable string with arguments property.

In order to dispatch the events for a typeable string with session , text and and keyboard , a remote end must for each , a remote end must for each char corresponding to an indexed property in corresponding to an indexed property in text : :

  1. If

    If char is a shifted character and the shifted state of is a shifted character and the shifted state of keyboard is false, create a new action object with is false, create a new action object with keyboard ’s ’s id , " , " key ", and " ", and " keyDown ", and set its ", and set its value property to U+E008 ("left shift"). Dispatch a keyDown action with this action object and property to U+E008 ("left shift"). Dispatch a keyDown action with session , this action object and keyboard ’s key input state . ’s key input state .

  2. If

    If char is not a shifted character and the shifted state of is not a shifted character and the shifted state of keyboard is true, create a new action object with is true, create a new action object with keyboard ’s ’s id , " , " key" ", and " ", and " keyUp ", and set its ", and set its value property to U+E008 ("left shift"). Dispatch a keyUp action with this action object and property to U+E008 ("left shift"). Dispatch a keyUp action with session , this action object and keyboard ’s key input state . ’s key input state .

  3. Let keydown action be a new action object constructed with arguments

    Let keydown action be a new action object constructed with arguments keyboard ’s ’s id , " , " key ", and " ", and " keyDown ". ".

  4. Set the

    Set the value property of keydown action to property of keydown action to char . .

  5. Dispatch a keyDown action with arguments keydown action and

    Dispatch a keyDown action with session , keydown action and keyboard ’s key input state . ’s key input state .

  6. Let keyup action be a copy of keydown action with the

    Let keyup action be a copy of keydown action with the subtype property changed to " property changed to " keyUp ". ".

  7. Dispatch a keyUp action with arguments keyup action and

    Dispatch a keyUp action with session , keyup action and keyboard ’s key input state . When required to dispatch a composition event with arguments ’s key input state .

When required to dispatch a composition event with type and and cluster , the remote end must perform implementation-specific action dispatch steps equivalent to sending composition events in accordance with the requirements of [ , the remote end must perform implementation-specific action dispatch steps equivalent to sending composition events in accordance with the requirements of [ UI-EVENTS ], and producing the following event with the specified properties. ], and producing the following event with the specified properties.

When required to dispatch actions for a string given session , text and and keyboard , a remote end must run the following steps: , a remote end must run the following steps:

  1. Let

    Let clusters be an array created by breaking be an array created by breaking text into extended grapheme clusters . into extended grapheme clusters .

  2. Let undo actions be an empty dictionary.

    Let undo actions be an empty dictionary.

  3. Let current typeable text be an empty string.

    Let current typeable text be an empty string.

  4. For each

    For each cluster corresponding to an indexed property in corresponding to an indexed property in clusters run the substeps of the first matching statement: run the substeps of the first matching statement:

    cluster is the null key is the null key
    1. Dispatch the events for a typeable string with arguments current typeable text and

      Dispatch the events for a typeable string with session , current typeable text and keyboard . Reset current typeable text to an empty string. . Reset current typeable text to an empty string.

    2. Clear the modifier key state with arguments being undo actions and

      Clear the modifier key state with arguments being undo actions and keyboard . .

    3. If the previous step results in an

      If the previous step results in an error , return that , return that error . .

    4. Reset undo actions to be an empty dictionary.

      Reset undo actions to be an empty dictionary.

    cluster is a modifier key is a modifier key
    1. Dispatch the events for a typeable string with arguments current typeable text and

      Dispatch the events for a typeable string with session , current typeable text and keyboard . Reset current typeable text to an empty string. . Reset current typeable text to an empty string.

    2. Let keydown action be an action object constructed with arguments

      Let keydown action be an action object constructed with arguments keyboard ’s ID, " ’s ID, " key ", and " ", and " keyDown ". ".

    3. Set the

      Set the value property of keydown action to property of keydown action to cluster . .

    4. Dispatch a keyDown action with arguments keydown action and

      Dispatch a keyDown action with session , keydown action and keyboard ’s key input state . ’s key input state .

    5. Add an entry to undo actions with key

      Add an entry to undo actions with key cluster and value being a copy of keydown action with the and value being a copy of keydown action with the subtype modified to " modified to " keyUp ". ".

    cluster is is typeable
    Append

    Append cluster to current typeable text . Otherwise to current typeable text .

    Otherwise
    1. Dispatch the events for a typeable string with arguments current typeable text and

      Dispatch the events for a typeable string with session , current typeable text and keyboard . Reset current typeable text to an empty string. . Reset current typeable text to an empty string.

    2. Dispatch a composition event

      Dispatch a composition event with arguments " with arguments " compositionstart " and " and undefined . .

    3. Dispatch a composition event

      Dispatch a composition event with arguments " with arguments " compositionupdate " and " and cluster . .

    4. Dispatch a composition event

      Dispatch a composition event with arguments " with arguments " compositionend " and " and cluster . .

  5. Dispatch the events for a typeable string with arguments current typeable text and

    Dispatch the events for a typeable string with session , current typeable text and keyboard . .

  6. Clear the modifier key state with arguments undo actions and

    Clear the modifier key state with arguments undo actions and keyboard . If an . If an error is returned, return that is returned, return that error The remote end steps for Element Send Keys are:

The remote end steps , given session , URL variables and parameters are:

  1. Let Let text be the result of getting a property called " be the result of getting a property named " text " from the " from parameters argument. .

  2. If If text is not a is not a String , return an error with , return an error code invalid argument . with error code invalid argument .

  3. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  4. Handle any user prompts , and return its value if it is an error . Try to handle any user prompts with session .

  5. Let Let element be the result of be the result of trying to get a known connected element with url variable element id . to get a known connected element with URL variables ' element id.

  6. Let Let file be true if be true if element is is input element in the file upload state , or false otherwise. element in the file upload state , or false otherwise.

  7. If If file is false or the current is false or the session ’s strict file interactability , is true run the following substeps: ’s strict file interactability , is true run the following substeps:

    1. Scroll into view the Scroll into view the element . .

    2. Wait in an implementation-specific way up to the session implicit wait timeout for Wait in an implementation-specific way up to the session implicit wait timeout for element to become to become keyboard-interactable . .

    3. If If element is not is not keyboard-interactable , return error with , return error code element not interactable . with error code element not interactable .

    4. If element is not the active If element run the focusing steps for the is not the active element run the focusing steps for the element . .

  8. Run the substeps of the first matching condition: Run the substeps of the first matching condition:

    file is true is true
    1. Let Let files be the result of splitting be the result of splitting text on the newline ( on the newline ( \n ) character. ) character.

    2. If If files is of 0 length, return an error with is of 0 length, return an error code invalid argument . with error code invalid argument .

    3. Let Let multiple equal the result of calling equal the result of calling hasAttribute ("multiple") on on element . .

    4. if if multiple is is false and the length of and the length of files is not equal to 1, return an error with is not equal to 1, return an error code invalid argument . with error code invalid argument .

    5. Verify that each file given by the user exists. If any do not, return error with Verify that each file given by the user exists. If any do not, return error code invalid argument . with error code invalid argument .

    6. Complete implementation specific steps equivalent to setting the selected files on the Complete implementation specific steps equivalent to setting the selected files on the input . If . If multiple is is true files are be appended to are be appended to element ’s selected files . ’s selected files .

    7. Fire these events in order on these events in order on element : :

      1. input
      2. change
    8. Return Return success with data with data null . .

    element is a non-typeable form control is a non-typeable form control
    1. If If element does not have an own property named does not have an own property named value return an error with return an error code element not interactable with error code element not interactable

    2. If If element is not is not mutable return an error with return an error code element not interactable . with error code element not interactable .

    3. Set a property Set a property value to to text on on element . .

    4. If If element is suffering from bad input return an error with is suffering from bad input return an error code invalid argument . with error code invalid argument .

    5. Return Return success with data with data null . .

    element is content editable If is content editable
    If element does not currently have focus, set the text insertion caret after any child content. Otherwise does not currently have focus, set the text insertion caret after any child content.
    Otherwise
    1. If If element does not currently have focus, let current text length be the does not currently have focus, let current text length be the length of of element ’s API value . ’s API value .

    2. Set the text insertion caret using set selection range using current text length for both the Set the text insertion caret using set selection range using current text length for both the start and and end parameters. parameters.

  9. Let Let keyboard be a new key input source . be a new key input source .

  10. Dispatch actions for a string with arguments Dispatch actions for a string with session , text and and keyboard . .

  11. Remove Remove keyboard from the current from the session ’s input state table ’s input state table

  12. Remove Remove keyboard from the list of active input sources . from the list of active input sources .

  13. Return Return success with data with data null . .

13. 13. Document

13.1 13.1 Get Page Source Get Page Source HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/source

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let source be the result of invoking the fragment serializing algorithm on a fictional node whose only child is the document element providing be the result of invoking the fragment serializing algorithm on a fictional node whose only child is the document element providing true for the require well-formed flag. If this causes an exception to be thrown, let for the require well-formed flag. If this causes an exception to be thrown, let source be be null . .

  4. Let Let source be the result of serializing to string session be the result of serializing to string the current browsing context active document , if 's current browsing context active document , if source is is null . .

  5. Return Return success with data with data source . .

13.2 Executing Script 13.2 Executing Script A

A collection is an is an Object that implements the that implements the Iterable interface, and whose: interface, and whose:

When required to JSON deserialize with argument value and optional argument and optional argument seen , a remote end must run the following steps: , a remote end must run the following steps:

  1. If If seen is not provided, let is not provided, let seen be an empty be an empty List . .

  2. Jump to the first appropriate step below: Jump to the first appropriate step below:

  3. Matching on Matching on value : :

    undefined
    null type
    type Boolean type
    type Number type
    type String

    Return Return success with data with data value . .

    Object that represents a web element that represents a web element

    Return the Return the deserialized web element of web element of value . instance of .

    instance of Array instance of
    instance of Object

    Return the result of running the clone an object algorithm with arguments Return the result of running the clone an object algorithm with arguments value and and seen , and the JSON deserialize algorithm as the clone algorithm. To perform a JSON clone return the result of calling the internal JSON clone algorithm with arguments , and the JSON deserialize algorithm as the clone algorithm.

To perform a JSON clone return the result of calling the internal JSON clone algorithm with arguments value and an empty and an empty List . When required to run the internal JSON clone algorithm with arguments .

When required to run the internal JSON clone algorithm with arguments value and and seen , a remote end must return the value of the first matching statement, matching on , a remote end must return the value of the first matching statement, matching on value : :

undefined
null

Success with data with data null . type .

type Boolean type
type Number type
type String

Success with data with data value . a .

a collection
  1. Let result list be an empty list. Let result list be an empty list.

  2. For each For each item of of value , add the result of , add the result of trying to clone an object with arguments to clone an object with arguments item and and seen and the internal JSON clone algorithm as the clone algorithm to result list . and the internal JSON clone algorithm as the clone algorithm to result list .

  3. Return Return success with result list . instance of with result list .

instance of element

If the If the element is stale , return error with is stale , return error code stale element reference . Otherwise return with error code stale element reference .

Otherwise return success with data set to the web element reference object for with data set to the web element reference object for value . a .

a WindowProxy object object

If the associated browsing context of the If the associated browsing context of the WindowProxy object in object in value has been has been discarded , return error with , return error code stale element reference . Otherwise return with error code stale element reference .

Otherwise return success with data set to with data set to WindowProxy reference object for reference object for value . has an own property named " .

has an own property named " toJSON " that is a " that is a Function Return
Return success with the value returned by with the value returned by Call ( toJSON ). ).
Otherwise
  1. If If value is in is in seen , return error with error code javascript , return error . with error code javascript error .

  2. Append Append value to to seen . .

  3. Let Let result be the value of running the clone an object algorithm with arguments be the value of running the clone an object algorithm with arguments value and and seen , and the internal JSON clone algorithm as the clone algorithm . , and the internal JSON clone algorithm as the clone algorithm .

  4. Remove the last element of Remove the last element of seen . .

  5. Return Return result . To clone an object , taking the arguments .

To clone an object , taking the arguments value , , seen , and clone algorithm : , and clone algorithm :

  1. Let Let result be the value of the first matching statement, matching on be the value of the first matching statement, matching on value : a :

    a collection

    A new A new Array which which length property is equal to the result of getting the property property is equal to the result of getting the property length of of value . Otherwise .

    Otherwise

    A new A new Object . .

  2. For each enumerable own property in For each enumerable own property in value , run the following substeps: , run the following substeps:

    1. Let name be the Let name of the property. be the name of the property.

    2. Let source property value be the result of getting a property named Let source property value be the result of getting a property named name from from value . If doing so causes script to be run and that script throws an error, return error with error code javascript . If doing so causes script to be run and that script throws an error, return error . with error code javascript error .

    3. Let cloned property result be the result of calling the clone algorithm with arguments source property value and Let cloned property result be the result of calling the clone algorithm with arguments source property value and seen . .

    4. If cloned property result is a If cloned property result is a success , set a property of , set a property of result with name with name name and value equal to cloned property result and value equal to cloned property result ’s data. ’s data.

    5. Otherwise, return cloned property result . When required to extract the script arguments from a request with argument Otherwise, return cloned property result .

When required to extract the script arguments from a request with argument parameters the implementation must: the implementation must:

  1. Let Let script be the result of getting a property named be the result of getting a property named " script from the " from parameters . .

  2. If If script is not a is not a String , return error with , return error code invalid argument . with error code invalid argument .

  3. Let Let args be the result of getting a property named be the result of getting a property named " args from the " from parameters . .

  4. If If args is not an is not an Array return error with return error code invalid argument . with error code invalid argument .

  5. Let arguments be the result of calling the JSON deserialize algorithm with Let arguments be the result of calling the JSON deserialize algorithm with arguments args . .

  6. Return Return success with data with data script and and arguments . The rules to execute a function body are as follows. The algorithm returns an ECMAScript completion record . If at any point during the algorithm a user prompt appears, immediately return .

The rules to execute a function body are as follows. The algorithm returns an ECMAScript completion record .

If at any point during the algorithm a user prompt appears, immediately return Completion { [[Type]]: { [[Type]]: normal , [[Value]]: , [[Value]]: null , [[Target]]: , [[Target]]: empty }, but continue to run the other steps of this algorithm in parallel. }, but continue to run the other steps of this algorithm in parallel.

  1. Let Let window be the associated window of session be the associated window of the current browsing context 's current browsing context ’s active document . ’s active document .

  2. Let environment settings be the environment settings object for Let environment settings be the environment settings object for window . Let global scope be environment settings .

  3. Let global scope be environment settings realm ’s global environment . ’s global environment .
  4. If If body is not parsable as a is not parsable as a FunctionBody or if parsing detects an early error , return or if parsing detects an early error , return Completion { [[Type]]: { [[Type]]: normal , [[Value]]: , [[Value]]: null , [[Target]]: , [[Target]]: empty }. }.

  5. If If body begins with a directive prologue that contains a use strict directive then let begins with a directive prologue that contains a use strict directive then let strict be true, otherwise let be true, otherwise let strict be false. be false.

  6. Prepare to run a script with environment settings . Prepare to run a script with environment settings .

  7. Prepare to run a callback with environment settings . Prepare to run a callback with environment settings .

  8. Let Let function be the result of calling be the result of calling FunctionCreate , with arguments: , with arguments:

    kind Normal.
    Normal.
    list An empty
    An empty List . .
    body The result of parsing
    The result of parsing body above. above.
    global scope The result of parsing global scope above. global scope
    The result of parsing global scope above.
    strict The result of parsing
    The result of parsing strict above. above.
  9. Let Let completion be be Call ( function , , window , , parameters ). ).

  10. Clean up after running a callback with environment settings . Clean up after running a callback with environment settings .

  11. Clean up after running a script with environment settings . Clean up after running a script with environment settings .

  12. Return Return completion . .

Note

The above algorithm is not associated with any particular element, and is therefore not subject to the document CSP The above algorithm is not associated with any particular element, and is therefore not subject to the document CSP directives . .

13.2.1 13.2.1 Execute Script Execute Script HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/execute/sync The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. Let Let body and and arguments be the result of be the result of trying to extract the script arguments from a request with argument to extract the script arguments from a request with argument parameters . .

  2. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  3. Handle any user prompts , and return its value if it is an error . Try to handle any user prompts with session .

  4. Let Let promise be a new Promise . be a new Promise .

  5. Run the following substeps in parallel : Run the following substeps in parallel :

    1. Let Let scriptPromise be the result of be the result of promise-calling execute a function body , with arguments execute a function body , with arguments body and and arguments . .

    2. Upon fulfillment of Upon fulfillment of scriptPromise with value with value v , , resolve promise with value with value v . .

    3. Upon rejection of Upon rejection of scriptPromise with value with value r , , reject promise with value with value r . .

  6. If If promise is still pending and the session script timeout is reached, return error with is still pending and the session script timeout is reached, return error code script timeout . with error code script timeout .

  7. Upon fulfillment of Upon fulfillment of promise with value with value v , let , let result be a JSON clone of be a JSON clone of v , and return , and return success with data with data result . .

  8. Upon rejection of Upon rejection of promise with reason with reason r , let , let result be a JSON clone of be a JSON clone of r , and return error with error code javascript , and return error and data with error code javascript error and data result . .

13.2.2 13.2.2 Execute Async Script Execute Async Script HTTP Method URI Template

HTTP Method URI Template
POST /session/{ session id session id }/execute/async
Note
The Execute Async Script

The Execute Async Script command causes JavaScript to execute as an anonymous function. An additional value is provided as the final argument to the function. This is a function that may be invoked to signal the completion of the asynchronous operation. The first argument provided to the function will be serialized to JSON and returned by Execute Async Script . causes JavaScript to execute as an anonymous function. An additional value is provided as the final argument to the function. This is a function that may be invoked to signal the completion of the asynchronous operation. The first argument provided to the function will be serialized to JSON and returned by Execute Async Script .

The remote end steps are: The remote end steps , given session , URL variables and parameters are:

  1. Let Let body and and arguments by the result of by the result of trying to extract the script arguments from a request with argument to extract the script arguments from a request with argument parameters . .

  2. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  3. Handle any user prompts , and return its value if it is an error . Try to handle any user prompts with session .

  4. Let Let promise be a new Promise . be a new Promise .

  5. Run the following substeps in parallel : Run the following substeps in parallel :

    1. Let Let resolvingFunctions be be CreateResolvingFunctions ( promise ). ).

    2. Append Append resolvingFunctions .[[Resolve]] to to arguments . .

    3. Let result be the Let result of calling execute a function body , with arguments be the result of calling execute a function body , with arguments body and and arguments . .

    4. If If scriptResult .[[Type]] is not .[[Type]] is not normal , then , then reject promise with value with value scriptResult .[[Value]], and abort these steps. .[[Value]], and abort these steps.

      Note

      Prior revisions of this specification did not recognize the return value of the provided script. In order to preserve legacy behavior, the return value only influences the command if it is a "thenable" object or if determining this produces an exception. Prior revisions of this specification did not recognize the return value of the provided script. In order to preserve legacy behavior, the return value only influences the command if it is a "thenable" object or if determining this produces an exception.

    5. If If Type ( scriptResult .[[Value]]) is not .[[Value]]) is not Object , then abort these steps. , then abort these steps.

    6. Let Let then be be Get ( scriptResult .[[Value]], "then"). .[[Value]], "then").

    7. If If then .[[Type]] is not .[[Type]] is not normal , then , then reject promise with value with value then .[[Value]], and abort these steps. .[[Value]], and abort these steps.

    8. If If IsCallable ( then .[[Type]]) is .[[Type]]) is false , then abort these steps. , then abort these steps.

    9. Let Let scriptPromise be be PromiseResolve ( Promise , , scriptResult .[[Value]]). .[[Value]]).

    10. Upon fulfillment of Upon fulfillment of scriptPromise with value with value v , , resolve promise with value with value v . .

    11. Upon rejection of Upon rejection of scriptPromise with value with value r , , reject promise with value with value r . .

  6. If If promise is still pending and session script timeout milliseconds is reached, return error with is still pending and session script timeout milliseconds is reached, return error code script timeout . with error code script timeout .

  7. Upon fulfillment of Upon fulfillment of promise with value with value v , let , let result be a JSON clone of be a JSON clone of v , and return , and return success with data with data result . .

  8. Upon rejection of Upon rejection of promise with reason with reason r , let , let result be a JSON clone of be a JSON clone of r , and return error with error code javascript , and return error and data with error code javascript error and data result . .

14. 14. Cookies This section describes the interaction with

This section describes the interaction with cookies as described in [ as described in [ RFC6265 ]. A ].

A cookie is described in [ is described in [ RFC6265 ] by a name-value pair holding the cookie’s data, followed by zero or more attribute-value pairs describing its characteristics. The following table for cookie conversion defines the cookie concepts relevant to WebDriver, how these are referred to in [ ] by a name-value pair holding the cookie’s data, followed by zero or more attribute-value pairs describing its characteristics.

The following table for cookie conversion defines the cookie concepts relevant to WebDriver, how these are referred to in [ RFC6265 ], what keys they map to in a serialized cookie , as well as the attribute-value keys needed when constructing a list of arguments for creating a cookie . For informational purposes, the table includes a legend of whether the field is optional in the serialized cookie provided to Add Cookie , and a brief non-normative description of the field and the expected input type of its associated value. Concept RFC 6265 Field JSON Key Attribute Key Optional Description ], what keys they map to in a serialized cookie , as well as the attribute-value keys needed when constructing a list of arguments for creating a cookie .

For informational purposes, the table includes a legend of whether the field is optional in the serialized cookie provided to Add Cookie , and a brief non-normative description of the field and the expected input type of its associated value.

Concept RFC 6265 Field JSON Key Attribute Key Optional Description
Cookie name Cookie name name " name " The name of the cookie. " The name of the cookie.
Cookie value Cookie value value " value " The cookie value. " The cookie value.
Cookie path Cookie path path " path " " " Path " ✓ The cookie path. Defaults to " " The cookie path. Defaults to " / " if omitted when adding a cookie . " if omitted when adding a cookie .
Cookie domain Cookie domain domain " domain " " " Domain " ✓ The domain the cookie is visible to. Defaults to the current browsing context " The domain the cookie is visible to. Defaults to session 's current browsing context ’s active document ’s active document ’s ’s URL domain if omitted when adding a cookie . if omitted when adding a cookie .
Cookie secure only Cookie secure only secure-only-flag " secure " " " Secure " ✓ Whether the cookie is a secure cookie. Defaults to false if omitted when adding a cookie . " Whether the cookie is a secure cookie. Defaults to false if omitted when adding a cookie .
Cookie HTTP only Cookie HTTP only http-only-flag " httpOnly " " " HttpOnly " ✓ Whether the cookie is an HTTP only cookie. Defaults to false if omitted when adding a cookie . " Whether the cookie is an HTTP only cookie. Defaults to false if omitted when adding a cookie .
Cookie expiry time Cookie expiry time expiry-time " expiry " " " Max-Age " ✓ When the cookie expires, specified in seconds since Unix Epoch . Must not be set if omitted when adding a cookie . " When the cookie expires, specified in seconds since Unix Epoch . Must not be set if omitted when adding a cookie .
Cookie same site Cookie same site samesite " sameSite " " " SameSite " ✓ Whether the cookie applies to a SameSite policy. Defaults to None if omitted when adding a cookie . Can be set to either " Whether the cookie applies to a SameSite policy. Defaults to None if omitted when adding a cookie . Can be set to either Lax or or Strict . A serialized cookie is a JSON .

A serialized cookie is a JSON Object where a where a cookie ’s [ ’s [ RFC6265 ] fields listed in the table for cookie conversion are mapped using the JSON Key and the associated field’s value from the cookie store . The optional fields may be omitted. To get all associated cookies to a ] fields listed in the table for cookie conversion are mapped using the JSON Key and the associated field’s value from the cookie store . The optional fields may be omitted.

To get all associated cookies to a document , the user agent must return the enumerated set of , the user agent must return the enumerated set of cookies that meet the requirements set out in the first step of the algorithm in [ that meet the requirements set out in the first step of the algorithm in [ RFC6265 ] to compute ] to compute cookie-string for an ‘HTTP API’, from the cookie store of the given for an ‘HTTP API’, from the cookie store of the given document ’s ’s address . The returned cookies must include HttpOnly cookies . When the remote end is instructed to create a cookie , this is synonymous to carrying out the steps described in [ . The returned cookies must include HttpOnly cookies .

When the remote end is instructed to create a cookie , this is synonymous to carrying out the steps described in [ RFC6265 ] section 5.3 , under receiving a cookie , except the user agent may not ignore the received cookie in its entirety (disregard step 1). To delete cookies given an optional filter argument ] section 5.3 , under receiving a cookie , except the user agent may not ignore the received cookie in its entirety (disregard step 1).

To delete cookies given an optional filter argument name that is a string: that is a string:

  1. For each For each cookie among all associated cookies of session 's current browsing context among all associated cookies of the current browsing context ’s active document , run the substeps of the first matching condition: ’s active document , run the substeps of the first matching condition:

    name is is undefined
    name is equal to cookie name is equal to cookie name

    Set the cookie expiry time to a Unix timestamp in the past. Otherwise Do nothing. Set the cookie expiry time to a Unix timestamp in the past.

    Otherwise
    Do nothing.

14.1 14.1 Get All Cookies Get All Cookies HTTP Method URI Template

HTTP Method URI Template
GET /session/{ session id session id }/cookie The remote end steps are:

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts , and return its value if it is an error . Try to handle any user prompts with session .

  3. Let Let cookies be a new JSON be a new JSON List . .

  4. For each For each cookie in all associated cookies of session in all associated cookies of the current browsing context 's current browsing context ’s active document : ’s active document :

    1. Let serialized cookie be the result of Let serialized cookie be the result of serializing cookie . .

    2. Append serialized cookie to Append serialized cookie to cookies

  5. Return Return success with data with data cookies . .

14.5 14.5 Delete All Cookies Delete All Cookies HTTP Method URI Template

HTTP Method URI Template
DELETE /session/{ session id session id }/cookie The remote end steps are: }/cookie

The remote end steps , given session , URL variables and parameters are:

  1. If the current browsing context is no longer open , return error with If session 's current browsing context is no longer open , return error code no such window . with error code no such window .

  2. Handle any user prompts , and return its value if it is an error . Try to handle any user prompts with session .

  3. Delete cookies , giving no filtering argument. Delete cookies , giving no filtering argument.

  4. Return Return success with data with data null . .

15. 15. Actions The Actions API provides a low-level interface for providing virtualised device input to the web browser. Conceptually, the Actions commands divide time into a series of

The Actions API provides a low-level interface for providing virtualised device input to the web browser. Conceptually, the Actions commands divide time into a series of ticks . The local end sends a series of actions which correspond to the change in state, if any, of each input device during each . The local end sends a series of actions which correspond to the change in state, if any, of each input device during each tick . For example, pressing a key is represented by an action sequence consisting of a single key input device and two . For example, pressing a key is represented by an action sequence consisting of a single key input device and two ticks , the first containing a , the first containing a keyDown action, and the second a action, and the second a keyUp action, whereas a pinch-zoom input is represented by an action sequence consisting of three action, whereas a pinch-zoom input is represented by an action sequence consisting of three ticks and two pointer input devices of type touch, each performing a sequence of actions and two pointer input devices of type touch, each performing a sequence of actions pointerDown , followed by , followed by pointerMove , and then , and then pointerUp . .

15.1 Input sources 15.1 Input sources

Note
The objects and properties defined in this section are spec-internal constructs and do not correspond to ECMAScript objects. For convenience the same terminology is used for their manipulation.

The objects and properties defined in this section are spec-internal constructs and do not correspond to ECMAScript objects. For convenience the same terminology is used for their manipulation.

An input source is a virtual device providing input events. Each input source has an associated input id , which is a string that identifies the particular device, and a source type which determines the kind of input the device can provide. As with real devices, virtual devices are stateful; this state is recorded in an input source state object associated with each input source . An input source is a virtual device providing input events. Each input source has an associated input id , which is a string that identifies the particular device, and a source type which determines the kind of input the device can provide. As with real devices, virtual devices are stateful; this state is recorded in an input source state object associated with each input source .

15.1.1 15.1.1 Sources A null input source is an input source that is not associated with a specific physical device. A null input source supports the following actions: Action Non-normative Description

A null input source is an input source that is not associated with a specific physical device. A null input source supports the following actions:

Action Non-normative Description
pause Used with an integer argument to specify the duration of a Used with an integer argument to specify the duration of a tick , or as a placeholder to indicate that an input source does nothing during a particular , or as a placeholder to indicate that an input source does nothing during a particular tick . A key input source is an input source that is associated with a keyboard-type device. A key input source supports the same

A key input source is an input source that is associated with a keyboard-type device. A key input source supports the same pause action as a null input source plus the following actions: Action Non-normative Description action as a null input source plus the following actions:

Action Non-normative Description
keyDown Used to indicate that a particular key should be held down. Used to indicate that a particular key should be held down.
keyUp Used to indicate that a depressed key should be released. A pointer input source is an input source that is associated with a pointer-type input device. Such an input source has an associated pointer type specifying exactly which kind of pointing device it is associated with. A pointer input source supports the same Used to indicate that a depressed key should be released.

A pointer input source is an input source that is associated with a pointer-type input device. Such an input source has an associated pointer type specifying exactly which kind of pointing device it is associated with. A pointer input source supports the same pause action as a null input source plus the following actions: Action Non-normative Description action as a null input source plus the following actions:

Action Non-normative Description
pointerDown Used to indicate that a pointer should be depressed in some way e.g. by holding a button down (for a mouse) or by coming into contact with the active surface (for a touch or pen device). Used to indicate that a pointer should be depressed in some way e.g. by holding a button down (for a mouse) or by coming into contact with the active surface (for a touch or pen device).
pointerUp Used to indicate that a pointer should be released in some way e.g. by releasing a mouse button or moving a pen or touch device away from the active surface. Used to indicate that a pointer should be released in some way e.g. by releasing a mouse button or moving a pen or touch device away from the active surface.
pointerMove Used to indicate a location on the screen that a pointer should move to, either in its active (pressed) or inactive state. Used to indicate a location on the screen that a pointer should move to, either in its active (pressed) or inactive state.
pointerCancel Used to cancel a pointer action. A wheel input source is an input source that is associated with a wheel-type input device. A wheel input source supports the same Used to cancel a pointer action.

A wheel input source is an input source that is associated with a wheel-type input device. A wheel input source supports the same pause action as a null input source plus the following actions: Action Non-normative Description action as a null input source plus the following actions:

Action Non-normative Description
scroll Used to indicate that the scroll wheel is rolled down, up, right or left to scroll the page down, up, right or left. Each Used to indicate that the scroll wheel is rolled down, up, right or left to scroll the page down, up, right or left.

Each session maintains a list of active input sources . This list is initially empty. When an input source is added to the maintains a list of active input sources , a corresponding entry is made in the input state table where the key is the input source ’s input id and the value is the input source ’s input source state . When an input source of active input sources . This list is initially empty. When an input source is added to the list of active input sources , a corresponding entry is made in the input state table where the key is the input source is removed from the list of active input sources , the corresponding entry in the input state table ’s input id and the value is the input source is also removed. ’s input source state . When an input source is removed from the list of active input sources , the corresponding entry in the input state table is also removed.

15.1.2 15.1.2 State Input source state is used as a generic term to describe the state associated with each input source . The corresponding input source state type for a label action type is given by the following table:

Input source state is used as a generic term to describe the state associated with each input source .

The corresponding input source state type for a label action type is given by the following table:

Action type Input state Action type Input state
" none " " null input state null input state
" key " " key input state key input state
" pointer " " pointer input state pointer input state
" wheel " " wheel input state A null input source ’s input source state is a null input state . This is always an empty object. A key input source wheel input state

A null input source ’s input source state ’s input source state is a null input state . This is always an empty object.

A key input source is a key input state object. This is an object with a property, pressed , which is a set of strings representing currently ’s input source state is a key input state object. This is an object with a property, pressed keys and properties , which is a set of strings representing currently pressed keys and properties alt , , shift , , ctrl , and , and meta , which are , which are Boolean s. When required to create a new key input state object , an implementation must return a key input state object with the s.

When required to create a new key input state object , an implementation must return a key input state object with the pressed property set to the empty set and property set to the empty set and alt , , shift , , ctrl , and , and meta all set to all set to false . A pointer input source ’s input source state .

A pointer input source is a pointer input state object. This consists of a ’s input source state is a pointer input state object. This consists of a subtype property, which has the possible values " property, which has the possible values " mouse ", " ", " pen ", and " ", and " touch ", a ", a pressed property which is a set of unsigned integers, an property which is a set of unsigned integers, an x property which is an unsigned integer, and a property which is an unsigned integer, and a y property which is an unsigned integer. When required to create a new pointer input state object with arguments property which is an unsigned integer.

When required to create a new pointer input state object with arguments subtype an implementation must return a pointer input state object with an implementation must return a pointer input state object with subtype set to set to subtype , , pressed set to an empty set and both set to an empty set and both x and and y set to set to 0 . A wheel input source ’s input source state .

A wheel input source is a wheel input state object. This is always an empty object. Each ’s input source state is a wheel input state object. This is always an empty object.

Each session has an associated input state table . This is a map between input id and the input source state for that input source , with one entry for each item in the list of active input sources . Each has an associated input state table . This is a map between input id and the input source state for that input source , with one entry for each item in the list of active input sources .

Each session also has an associated input cancel list , which is a list of actions. This list is used to manage dispatching events when resetting the state of the input source also has an associated input cancel list , which is a list of actions. This list is used to manage dispatching events when resetting the state of the input source s. For simplicity the algorithms described here only append actions to the list and rely on the fact that the reset operations are idempotent. The calculated global key state is the aggregated key state from all key input state objects. It can be calculated this way: s. For simplicity the algorithms described here only append actions to the list and rely on the fact that the reset operations are idempotent.

The calculated global key state is the aggregated key state from all key input state objects. It can be calculated this way:

  1. Let Let pressed be a new Set. be a new Set.

  2. Let Let alt , , ctrl , , meta , and , and shift be the be the Boolean false value. value.

  3. For enumerable own property in the input state table : For enumerable own property in the input state table :

    1. Let Let source be the value of the property. be the value of the property.

    2. If If source is not a key input state , continue to the first step of this loop. is not a key input state , continue to the first step of this loop.

    3. Let key state pressed be the result of getting a property named Let key state pressed be the result of getting a property named " pressed from " from source . .

    4. Add all strings from key state pressed to Add all strings from key state pressed to pressed . Let .

    5. Let alt be a logical OR of be a logical OR of alt and the result of getting a property named and the result of getting a property named " alt from " from source . Let .
    6. Let ctrl be a logical OR of be a logical OR of ctrl and the result of getting a property named and the result of getting a property named " ctrl from " from source . Let .
    7. Let meta be a logical OR of be a logical OR of meta and the result of getting a property named and the result of getting a property named " meta from " from source . Let .
    8. Let shift be a logical OR of be a logical OR of shift and the result of getting a property named and the result of getting a property named " shift from " from source . .
  4. Let Let state be a new JSON be a new JSON Object . .

  5. Set a property on Set a property on state with name with name pressed and value and value pressed . .

  6. Set a property on Set a property on state with name with name alt and value and value alt . .

  7. Set a property on Set a property on state with name with name ctrl and value and value ctrl . .

  8. Set a property on Set a property on state with name with name meta and value and value meta . .

  9. Set a property on Set a property on state with name with name shift and value and value shift . .

  10. Return Return state . .

15.2 15.2 Ticks A

A tick is the basic unit of time over which actions can be performed. During a is the basic unit of time over which actions can be performed. During a tick , each input source has an assigned action — possibly a noop , each input source has an assigned action — possibly a noop pause action — which may result in changes to the user agent internal state and eventually cause DOM events to be action — which may result in changes to the user agent internal state and eventually cause DOM events to be fired at the page. The next at the page. The next tick begins after the user agent has had a chance to process all DOM events generated in the current begins after the user agent has had a chance to process all DOM events generated in the current tick . .

Waiting asynchronously means waiting for something to occur whilst allowing the browser to continue processing the event loop . At the lowest level, the behavior of actions is intended to mimic the remote end ’s behavior with an actual input device as closely as possible, and the implementation strategy may involve e.g. injecting synthesized events into a browser event loop. Therefore the steps to dispatch an action will inevitably end up in implementation-specific territory. However there are certain content observable effects that must be consistent across implementations. To accommodate this, the specification requires that remote ends perform implementation-specific action dispatch steps , along with a list of events and their properties. This list is not comprehensive; in particular the default action of the input source Waiting asynchronously means waiting for something to occur whilst allowing the browser to continue processing the event loop .

At the lowest level, the behavior of actions is intended to mimic the remote end may cause additional events to be generated depending on the implementation and the state of the browser (e.g. input events relating to key actions when the focus is on an editable ’s behavior with an actual input device as closely as possible, and the implementation strategy may involve e.g. injecting synthesized events into a browser event loop. Therefore the steps to dispatch an action will inevitably end up in implementation-specific territory. However there are certain content observable effects that must be consistent across implementations. To accommodate this, the specification requires that remote ends perform implementation-specific action dispatch steps , along with a list of events and their properties. This list is not comprehensive; in particular the default action of the input source may cause additional events to be generated depending on the implementation and the state of the browser (e.g. input events relating to key actions when the focus is on an editable element , scroll events, etc.). , scroll events, etc.).

Note
An activation trigger generated by WebDriver needs to be indistinguishable from those generated by a real user interacting with the browser. In particular, the dispatched events will have the

15.3 Processing actions 15.3 Processing actions The algorithm for <a a="" data-link-type=dfn from="" sequence="" id=ref-for-dfn-extract-an-action-sequence-1 an="" href=#dfn-extract-an-action-sequence request

The algorithm for <="" action="" data-lt="extract an action sequence" class=internalDFN extracting=""> takes the JSON Object representing an action sequence, validates the input, and returns a data structure that is the transpose of the input JSON, such that the actions to be performed in a single tick are grouped together.

When required to extract an action sequence with argument parameters , a remote end must run the following steps:

  1. Let actions be the result of getting a property parameters named " actions " from parameters .

  2. If actions is undefined or is not an Array , return error with error code invalid argument .

  3. Let actions by tick be an empty List .

  4. For each value action sequence corresponding to an indexed property in actions :

    1. Let input source actions be the result of trying to process an input source action sequence with argument action sequence .

    2. For each action in input source actions :

      1. Let i be the zero-based index of action in input source actions .

      2. If the length of actions by tick is less than i + 1, append a new List to actions by tick .

      3. Append action to the List at index i in actions by tick .

  5. Return Return success with data actions by tick .

When required to process an input source action sequence , with argument action sequence , a remote end must run the following steps:

  1. Let type be the result of getting a property named " type " from action sequence .

  2. If type is not " key ", " pointer ", " wheel ", or " none ", return an ", return an error with error code invalid argument .

  3. Let id be the result of getting the property id from action sequence .

  4. If id is undefined or is not a String , return error with error code invalid argument .

  5. If type is equal to " pointer ", let parameters data be the result of getting the property " parameters " from action sequence . Then let parameters be the result of trying to process pointer parameters with argument parameters data .

  6. Let source be the input source in the list of active input sources where that input source ’s input id is equal to id , or undefined if there is no matching input source .

  7. If source is undefined :

    1. Let source be a new input source created from the first match against type :
      " none "
      Create a new null input source .
      " key "
      Create a new key input source .
      " pointer "
      Create a new pointer input source . Let the new input source ’s pointer type be set to the value of parameters ’s pointerType property.
      " wheel "
      Create a new wheel input source .
    2. Add source current session to the session ’s list of active input sources .

    3. Add source ’s input source state current session to the session ’s input state table , keyed on source ’s input id .

  8. If source ’s source type is not equal to type return an error with error code invalid argument .

  9. If parameters is not undefined , then if its pointerType property is not equal to source ’s pointer type , return an error with error code invalid argument .

  10. Let action items be the result of getting a property named " actions " from action sequence .

  11. If action items is not an Array , return error with error code invalid argument .

  12. Let actions be a new list.

  13. For each action item in action items :

    1. If action item is not an Object return error with error code invalid argument .

    2. If type is " none " let action be the result of trying to process a null action with parameters id , and action item .

    3. Otherwise, if type is " key " let action be the result of trying to process a key action with parameters id , and action item .

    4. Otherwise, if type is " pointer " let action be the result of trying to process a pointer action with parameters id , parameters , and action item .

    5. Otherwise, if type is " wheel " let action be the result of trying to process a wheel action with parameters id , and action item .

    6. Append action to actions .

  14. Return Return success with data actions .

The default pointer parameters consist of an object with property pointerType set to mouse .

When required to process pointer parameters with argument parameters data , a remote end must perform the following steps:

  1. Let parameters be the default pointer parameters .

  2. If parameters data is undefined , return success with data parameters .

  3. If parameters data is not an Object , return error with error code invalid argument .

  4. Let pointer type be the result of getting a property named " pointerType " from parameters data .

  5. If pointer type is not undefined :

    1. If pointer type does not have one of the values " mouse ", " pen ", or " touch ", return ", return error with error code invalid argument .

    2. Set the pointerType property of parameters to pointer type .

  6. Return Return success with data parameters .

An action object constructed with arguments id , type , and subtype is an object with property id set to id , type set to type and subtype set to subtype . Specific action objects have further properties added by other algorithms in this specification.

When required to process a null action with arguments id and action item , a remote end must perform the following steps:

  1. Let subtype be the result of getting a property named " type " from action item .

  2. If subtype is not " pause ", return ", return error with error code invalid argument .

  3. Let action be an action object constructed with arguments id , "none" , and subtype .

  4. Let result be the result of trying to process a pause action with arguments action item and action .

  5. Return result .

When required to process a key action with arguments id and action item , a remote end must perform the following steps:

  1. Let subtype be the result of getting a property named " type " from action item .

  2. If subtype is not one of the values " keyUp ", " keyDown ", or " pause ", return an ", return an error with error code invalid argument .

  3. Let action be an action object constructed with arguments id , " key ", and subtype .

  4. If subtype is " pause ", let result be the result of trying to process a pause action with arguments action item and action , and return result .

  5. Let key be the result of getting a property named " value " from action item .

  6. If key is not a String containing a single unicode code point or grapheme cluster? return error with error code invalid argument .

  7. Set the value property on action to key .

  8. Return success with data action .

When required to process a pointer action with arguments id , parameters , and action item , a remote end must perform the following steps:

  1. Let subtype be the result of getting a property named " type " from action item .

  2. If subtype is not one of the values " pause ", " pointerUp ", " pointerDown ", " pointerMove ", or " pointerCancel ", return an ", return an error with error code invalid argument .

  3. Let action be an action object constructed with arguments id , " pointer ", and subtype .

  4. If subtype is " pause ", let result be the result of trying to process a pause action with arguments action item and action , and return result .

  5. Set the pointerType property of action equal to the pointerType property of parameters .

  6. If subtype is " pointerUp " or " pointerDown ", process a pointer up or pointer down action with arguments action item and action . If doing so results in an error , return that error .

  7. If subtype is " pointerMove " process a pointer move action with arguments action item and action . If doing so results in an error , return that error .

  8. If subtype is " pointerCancel " process a pointer cancel action . If doing so results in an error , return that error .

  9. Return success with data action .

When required to process a wheel action with arguments id , and action item , a remote end must perform the following steps:

  1. Let subtype be the result of getting a property named " type " from action item .

  2. If subtype is not the value " pause ", or " scroll ", return an ", return an error with error code invalid argument .

  3. Let action be an action object constructed with arguments id , " wheel ", and subtype .

  4. If subtype is " pause ", let result be the result of trying to process a pause action with arguments action item and action , and return result .

  5. Let duration be the result of getting a property named " duration " from action item .

  6. If duration is not undefined and duration is not an Integer greater than or equal to 0, return error with error code invalid argument .

  7. Set the duration property of action to duration .

  8. Let origin be the result of getting the property origin from action item .

  9. If origin is undefined let origin equal " viewport ".

  10. If origin is not equal to " viewport " or " pointer " and origin is not an Object that represents a web element , return error with error code invalid argument .

  11. Set the origin property of action to origin .

  12. Let x be the result of getting the property x from action item .

  13. If x is not undefined and is not an Integer , return error with error code invalid argument .

  14. Set the x property of action to x .

  15. Let y be the result of getting the property y from action item .

  16. If y is not undefined and is not an Integer , return error with error code invalid argument .

  17. Set the y property of action to y .

  18. Let deltaX be the result of getting the property deltaX from action item .

  19. If deltaX is not undefined and is not an Integer , return error with error code invalid argument .

  20. Set the deltaX property of action to deltaX .

  21. Let deltaY be the result of getting the property deltaY from action item .

  22. If deltaY is not undefined and is not an Integer , return error with error code invalid argument .

  23. Set the deltaY property of action to deltaY .

  24. Return success with data action .

When required to process a pause action with arguments action item , and action , a remote end must run the following steps:

  1. Let duration be the result of getting the property " duration " from action item .

  2. If duration is not undefined and duration is not an Integer greater than or equal to 0, return error with error code invalid argument .

  3. Set the duration property of action to duration .

  4. Return success with data action .

When required to process a pointer up or pointer down action with arguments action item , and action , a remote end must run the following steps:

  1. Let button be the result of getting the property button from action item .

  2. If button is not an Integer greater than or equal to 0 return error with error code invalid argument .

  3. Set the button property of action to button .

  4. Let width be the result of getting the property width from action item .

  5. If width is not undefined and width is not a Number greater than or equal to 0 return error with error code invalid argument .

  6. Set the width property of action to width .

  7. Let height be the result of getting the property height from action item .

  8. If height is not undefined and height is not a Number greater than or equal to 0 return error with error code invalid argument .

  9. Set the height property of action to height .

  10. Let pressure be the result of getting the property pressure from action item .

  11. If pressure is not undefined and pressure is not a Number greater than or equal to 0 and less than or equal to 1 return error with error code invalid argument .

  12. Set the pressure property of action to pressure .

  13. Let tangentialPressure be the result of getting the property tangentialPressure from action item .

  14. If tangentialPressure is not undefined and tangentialPressure is not a Number greater than or equal to -1 and less than or equal to 1 return error with error code invalid argument .

  15. Set the tangentialPressure property of action to tangentialPressure .

  16. Let tiltX be the result of getting the property tiltX from action item .

  17. If tiltX is not undefined and tiltX is not an Integer greater than or equal to -90 and less than or equal to 90 return error with error code invalid argument .

  18. Set the tiltX property of action to tiltX .

  19. Let tiltY be the result of getting the property tiltY from action item .

  20. If tiltY is not undefined and tiltY is not an Integer greater than or equal to -90 and less than or equal to 90 return error with error code invalid argument .

  21. Set the tiltY property of action to tiltY .

  22. Let twist be the result of getting the property twist from action item .

  23. If twist is not undefined and twist is not an Integer greater than or equal to 0 and less than or equal to 359 return error with error code invalid argument .

  24. Set the twist property of action to twist .

  25. Let altitudeAngle be the result of getting the property altitudeAngle from action item .

  26. If altitudeAngle is not undefined and altitudeAngle is not a Number greater than or equal to 0 and less than or equal to π/2 return error with error code invalid argument .

  27. Set the altitudeAngle property of action to altitudeAngle .

  28. Let azimuthAngle be the result of getting the property azimuthAngle from action item .

  29. If azimuthAngle is not undefined and azimuthAngle is not a Number greater than or equal to 0 and less than or equal to 2π return error with error code invalid argument .

  30. Set the azimuthAngle property of action to azimuthAngle .

  31. Return success with data Return success with data null .

When required to process a pointer move action with arguments action item , and action , a remote end must run the following steps:

  1. Let duration be the result of getting the property duration from action item .

  2. If duration is not undefined and duration is not an Integer greater than or equal to 0, return error with error code invalid argument .

  3. Set the duration property of action to duration .

  4. Let origin be the result of getting the property origin from action item .

  5. If origin is undefined let origin equal " viewport ".

  6. If origin is not equal to " viewport " or " pointer " and origin is not an Object that represents a web element , return error with error code invalid argument .

  7. Set the origin property of action to origin .

  8. Let x be the result of getting the property x from action item .

  9. If x is not undefined and is not an Integer , return error with error code invalid argument .

  10. Set the x property of action to x .

  11. Let y be the result of getting the property y from action item .

  12. If y is not undefined and is not an Integer , return error with error code invalid argument .

  13. Set the y property of action to y .

  14. Let width be the result of getting the property width from action item .

  15. If width is not undefined and width is not a Number greater than or equal to 0 return error with error code invalid argument .

  16. Set the width property of action to width .

  17. Let height be the result of getting the property height from action item .

  18. If height is not undefined and height is not a Number greater than or equal to 0 return error with error code invalid argument .

  19. Set the height property of action to height .

  20. Let pressure be the result of getting the property pressure from action item .

  21. If pressure is not undefined and pressure is not a Number greater than or equal to 0 and less than or equal to 1 return error with error code invalid argument .

  22. Set the pressure property of action to pressure .

  23. Let tangentialPressure be the result of getting the property tangentialPressure from action item .

  24. If tangentialPressure is not undefined and tangentialPressure is not a Number greater than or equal to -1 and less than or equal to 1 return error with error code invalid argument .

  25. Set the tangentialPressure property of action to tangentialPressure .

  26. Let tiltX be the result of getting the property tiltX from action item .

  27. If tiltX is not undefined and tiltX is not an Integer greater than or equal to -90 and less than or equal to 90 return error with error code invalid argument .

  28. Set the tiltX property of action to tiltX .

  29. Let tiltY be the result of getting the property tiltY from action item .

  30. If tiltY is not undefined and tiltY is not an Integer greater than or equal to -90 and less than or equal to 90 return error with error code invalid argument .

  31. Set the tiltY property of action to tiltY .

  32. Let twist be the result of getting the property twist from action item .

  33. If twist is not undefined and twist is not an Integer greater than or equal to 0 and less than or equal to 359 return error with error code invalid argument .

  34. Set the twist property of action to twist .

  35. Let altitudeAngle be the result of getting the property altitudeAngle from action item .

  36. If altitudeAngle is not undefined and altitudeAngle is not a Number greater than or equal to 0 and less than or equal to π/2 return error with error code invalid argument .

  37. Set the altitudeAngle property of action to altitudeAngle .

  38. Let azimuthAngle be the result of getting the property azimuthAngle from action item .

  39. If azimuthAngle is not undefined and azimuthAngle is not a Number greater than or equal to 0 and less than or equal to 2π return error with error code invalid argument .

  40. Set the azimuthAngle property of action to azimuthAngle .

  41. Return success with data Return success with data null .

15.4 Dispatching actions

The algorithm to dispatch actions takes a list of actions grouped by tick , and then causes each action to be run at the appropriate point in the sequence.

When asked to To dispatch actions given session , and actions by tick , a remote end must run the following steps:

  1. For each item tick actions in actions by tick :

    1. Let tick duration be the result of computing the tick duration with argument tick actions .

    2. Dispatch tick actions with session , tick actions , and tick duration . If this results in an error return that error.

    3. Wait until the following conditions are all met:

  2. Return success with data Return success with data null .

When required to compute the tick duration with argument tick actions , a remote end must take the following steps:

  1. Let max duration be 0.

  2. For each action object in tick actions :

    1. let duration be undefined .

    2. If action object has subtype property set to " pause " or action object has type property set to " pointer " and subtype property set to " pointerMove ", or action object has type property set to " wheel " and subtype property set to " scroll ", let duration be equal to the duration property of action object .

    3. If duration is not undefined , and duration is greater than max duration , let max duration be equal to duration.

  3. Return max duration .

When required to To dispatch tick actions given session , tick actions and tick duration , a remote end must run the following steps:

  1. For each action object in tick actions :

    1. Let source id be equal to the value of action object ’s id property.

    2. Let source type be equal to the value of action object ’s type property.

    3. If the current session If the session ’s input state table doesn’t have a property corresponding to source id , then let the property corresponding to source id be a new object of the corresponding input source state type for source type .

    4. Let device state be the input source state corresponding to source id current session in the session ’s input state table .

    5. Let algorithm be the value of the column dispatch action algorithm from the following table of dispatch action algorithms that is equal to the source type and the action object ’s subtype property, to a dispatch action algorithm.

      source type subtype property Dispatch action algorithm
      " none " " pause " Dispatch a pause action
      " key " " pause " Dispatch a pause action
      " key " " keyDown " Dispatch a keyDown action
      " key " " keyUp " Dispatch a keyUp action
      " pointer " " pause " Dispatch a pause action
      " pointer " " pointerDown " Dispatch a pointerDown action
      " pointer " " pointerUp " Dispatch a pointerUp action
      " pointer " " pointerMove Dispatch a pointerMove action
      " pointer " " pointerCancel Dispatch a pointerCancel action
      " wheel " " pause " Dispatch a pause action
      " wheel " " scroll " Dispatch a scroll action
    6. Try to run algorithm with session , source id , action object , device state and tick duration .
  2. Return Return success with data null .

15.4.1 General actions

When required to dispatch a pause action given session , source id , action object , input state and tick duration a remote end must run the following steps:

  1. Return Return success with data null .

15.4.2 Keyboard actions

The normalised key value for a raw key key is, if key appears in the table below, the string value in the second column on the row containing key ’s unicode code point in the first column, otherwise it is key .

key ’s codepoint Normalised key value
\uE000 "Unidentified"
\uE001 "Cancel"
\uE002 "Help"
\uE003 "Backspace"
\uE004 "Tab"
\uE005 "Clear"
\uE006 "Return"
\uE007 "Enter"
\uE008 "Shift"
\uE009 "Control"
\uE00A "Alt"
\uE00B "Pause"
\uE00C "Escape"
\uE00D " "
\uE00E "PageUp"
\uE00F "PageDown"
\uE010 "End"
\uE011 "Home"
\uE012 "ArrowLeft"
\uE013 "ArrowUp"
\uE014 "ArrowRight"
\uE015 "ArrowDown"
\uE016 "Insert"
\uE017 "Delete"
\uE018 ";"
\uE019 "="
\uE01A "0"
\uE01B "1"
\uE01C "2"
\uE01D "3"
\uE01E "4"
\uE01F "5"
\uE020 "6"
\uE021 "7"
\uE022 "8"
\uE023 "9"
\uE024 "*"
\uE025 "+"
\uE026 ","
\uE027 "-"
\uE028 "."
\uE029 "/"
\uE031 "F1"
\uE032 "F2"
\uE033 "F3"
\uE034 "F4"
\uE035 "F5"
\uE036 "F6"
\uE037 "F7"
\uE038 "F8"
\uE039 "F9"
\uE03A "F10"
\uE03B "F11"
\uE03C "F12"
\uE03D "Meta"
\uE040 "ZenkakuHankaku"
\uE050 "Shift"
\uE051 "Control"
\uE052 "Alt"
\uE053 "Meta"
\uE054 "PageUp"
\uE055 "PageDown"
\uE056 "End"
\uE057 "Home"
\uE058 "ArrowLeft"
\uE059 "ArrowUp"
\uE05A "ArrowRight"
\uE05B "ArrowDown"
\uE05C "Insert"
\uE05D "Delete"

The code for key is the value in the last column of the following table on the row with key in either the first or second column, if any such row exists, otherwise it is undefined .

A shifted character is one that appears in the second column of the following table.

Key Alternate Key code
"`" "~" "Backquote"
"\" "|" "Backslash"
"\uE003" "Backspace"
"[" "{" "BracketLeft"
"]" "}" "BracketRight"
"," "<" "Comma"
"0" ")" "Digit0"
"1" "!" "Digit1"
"2" "@" "Digit2"
"3" "#" "Digit3"
"4" "$" "Digit4"
"5" "%" "Digit5"
"6" "^" "Digit6"
"7" "&" "Digit7"
"8" "*" "Digit8"
"9" "(" "Digit9"
"=" "+" "Equal"
"<" ">" "IntlBackslash"
"a" "A" "KeyA"
"b" "B" "KeyB"
"c" "C" "KeyC"
"d" "D" "KeyD"
"e" "E" "KeyE"
"f" "F" "KeyF"
"g" "G" "KeyG"
"h" "H" "KeyH"
"i" "I" "KeyI"
"j" "J" "KeyJ"
"k" "K" "KeyK"
"l" "L" "KeyL"
"m" "M" "KeyM"
"n" "N" "KeyN"
"o" "O" "KeyO"
"p" "P" "KeyP"
"q" "Q" "KeyQ"
"r" "R" "KeyR"
"s" "S" "KeyS"
"t" "T" "KeyT"
"u" "U" "KeyU"
"v" "V" "KeyV"
"w" "W" "KeyW"
"x" "X" "KeyX"
"y" "Y" "KeyY"
"z" "Z" "KeyZ"
"-" "_" "Minus"
"." ">"." "Period"
"'" """ "Quote"
";" ":" "Semicolon"
"/" "?" "Slash"
"\uE00A" "AltLeft"
"\uE052" "AltRight"
"\uE009" "ControlLeft"
"\uE051" "ControlRight"
"\uE006" "Enter"
"\uE03D" "OSLeft"
"\uE053" "OSRight"
"\uE008" "ShiftLeft"
"\uE050" "ShiftRight"
" " "\uE00D" "Space"
"\uE004" "Tab"
"\uE017" "Delete"
"\uE010" "End"
"\uE002" "Help"
"\uE011" "Home"
"\uE016" "Insert"
"\uE00F" "PageDown"
"\uE00E" "PageUp"
"\uE015" "ArrowDown"
"\uE012" "ArrowLeft"
"\uE014" "ArrowRight"
"\uE013" "ArrowUp"
"\uE00C" "Escape"
"\uE031" "F1"
"\uE032" "F2"
"\uE033" "F3"
"\uE034" "F4"
"\uE035" "F5"
"\uE036" "F6"
"\uE037" "F7"
"\uE038" "F8"
"\uE039" "F9"
"\uE03A" "F10"
"\uE03B" "F11"
"\uE03C" "F12"
"\uE01A" "\uE05C" "Numpad0"
"\uE01B" "\uE056" "Numpad1"
"\uE01C" "\uE05B" "Numpad2"
"\uE01D" "\uE055" "Numpad3"
"\uE01E" "\uE058" "Numpad4"
"\uE01F" "Numpad5"
"\uE020" "\uE05A" "Numpad6"
"\uE021" "\uE057" "Numpad7"
"\uE022" "\uE059" "Numpad8"
"\uE023" "\uE054" "Numpad9"
"\uE025" "NumpadAdd"
"\uE026" "NumpadComma"
"\uE028" "\uE05D" "NumpadDecimal"
"\uE029" "NumpadDivide"
"\uE007" "NumpadEnter"
"\uE024" "NumpadMultiply"
"\uE027" "NumpadSubtract"

The key location for key is the value in the last column in the table below on the row with key appears in the first column, if such a row exists, otherwise it is 0 .

key ’s codepoint Description Location
\uE007 Enter 1
\uE008 Left Shift 1
\uE009 Left Control 1
\uE00A Left Alt 1
\uE01A Numpad 0 3
\uE01B Numpad 1 3
\uE01C Numpad 2 3
\uE01D Numpad 3 3
\uE01E Numpad 4 3
\uE01F Numpad 5 3
\uE020 Numpad 6 3
\uE021 Numpad 7 3
\uE022 Numpad 8 3
\uE023 Numpad 9 3
\uE024 Numpad * 3
\uE025 Numpad + 3
\uE026 Numpad , 3
\uE027 Numpad - 3
\uE028 Numpad . 3
\uE029 Numpad / 3
\uE03D Left Meta 1
\uE050 Right Shift 2
\uE051 Right Control 2
\uE052 Right Alt 2
\uE053 Right Meta 2
\uE054 Numpad PageUp 3
\uE055 Numpad PageDown 3
\uE056 Numpad End 3
\uE057 Numpad Home 3
\uE058 Numpad ArrowLeft 3
\uE059 Numpad ArrowUp 3
\uE05A Numpad ArrowRight 3
\uE05B Numpad ArrowDown 3
\uE05C Numpad Insert 3
\uE05D Numpad Delete 3

When required to dispatch a keyDown action given session , source id , action object , input state and tick duration a remote end must run the following steps:

  1. Let raw key be equal to the action object ’s value property.

  2. Let key be equal to the normalised key value for raw key .

  3. If the input state ’s pressed property contains key , let repeat be true, otherwise let repeat be false.

  4. Let code be the code for raw key .

  5. Let location be the key location for raw key .

  6. Let charCode , keyCode and which be the implementation-specific values of the charCode , keyCode and which properties appropriate for a key with key key and location location on a 102 key US keyboard, following the guidelines in [ UI-EVENTS ].

  7. If key is "Alt" , let device state’s alt property be true.

  8. If key is "Shift" , let device state’s shift property be true.

  9. If key is "Control" , let device state’s ctrl property be true.

  10. If key is "Meta" , let device state’s meta property be true.

  11. Add key to the set corresponding to input state ’s pressed property.

  12. Append a copy of action object with the subtype property changed to " keyUp " to current session " to session ’s input cancel list .

  13. Perform implementation-specific action dispatch steps equivalent to pressing a key on the keyboard in accordance with the requirements of [ UI-EVENTS ], and producing the following events, as appropriate, with the specified properties. This will always produce events including at least a keyDown event.

    • keyDown with properties:
      Attribute Value
      key key
      code code
      location location
      altKey device state ’s alt property
      shiftKey device state ’s shift property
      ctrlKey device state ’s ctrl property
      metaKey device state ’s meta property
      repeat repeat
      isComposing false
      charCode charCode
      keyCode keyCode
      which which
    • keyPress with properties:
      Attribute Value
      key key
      code code
      location location
      altKey device state ’s alt property
      shiftKey device state ’s shift property
      ctrlKey device state ’s ctrl property
      metaKey device state ’s meta property
      repeat repeat
      isComposing false
      charCode charCode
      keyCode keyCode
      which which
  14. Return Return success with data null .

Note

When required to To dispatch a keyUp action , given session , source id , action object , input state and tick duration a remote end must run the following steps:

  1. Let raw key be equal to action object ’s value property.

  2. Let key be equal to the normalised key value for raw key .

  3. If the input state ’s pressed property does not contain key , return.

  4. Let code be the code for raw key .

  5. Let location be the key location for raw key .

  6. Let charCode , keyCode and which be the implementation-specific values of the charCode , keyCode and which properties appropriate for a key with key key and location location on a 102 key US keyboard, following the guidelines in [ UI-EVENTS ].

  7. If key is "Alt" , let device state’s alt property be false.

  8. If key is "Shift" , let device state’s shift property be false.

  9. If key is "Control" , let device state’s ctrl property be false.

  10. If key is "Meta" , let device state’s meta property be false.

  11. Remove key from the set corresponding to input state ’s pressed property.

  12. Perform implementation-specific action dispatch steps equivalent to releasing a key on the keyboard in accordance with the requirements of [ UI-EVENTS ], and producing at least the following events with the specified properties:

    • keyup , with properties:
      Attribute Value
      key key
      code code
      location location
      altKey device state ’s alt property
      shiftKey device state ’s shift property
      ctrlKey device state ’s ctrl property
      metaKey device state ’s meta property
      repeat false
      isComposing false
      charCode charCode
      keyCode keyCode
      which which
  13. Return Return success with data null .

15.4.3 Pointer actions

When required to To dispatch a pointerDown action given session , source id , action object , input state and tick duration a remote end must run the following steps:

  1. Let pointerType be equal to action object ’s pointerType property.

  2. Let button be equal to action object ’s button property.

  3. If the input state ’s pressed property contains button return success with data null .

  4. Let x be equal to input state ’s x property.

  5. Let y be equal to input state ’s y property.

  6. Add button to the set corresponding to input state ’s pressed property, and let buttons be the resulting value of that property.

  7. Let width be equal to action object ’s width property.

  8. Let height be equal to action object ’s height property.

  9. Let pressure be equal to action object ’s pressure property.

  10. Let tangentialPressure be equal to action object ’s tangentialPressure property.

  11. Let tiltX be equal to action object ’s tiltX property.

  12. Let tiltY be equal to action object ’s tiltY property.

  13. Let twist be equal to action object ’s twist property.

  14. Let altitudeAngle be equal to action object ’s altitudeAngle property.

  15. Let azimuthAngle be equal to action object ’s azimuthAngle property.

  16. Append a copy of action object with the subtype property changed to " pointerUp " to the current session " to the session ’s input cancel list .

  17. Perform implementation-specific action dispatch steps equivalent to pressing the button numbered button on the pointer with ID source id , having type pointerType at viewport x coordinate x , viewport y coordinate y , width , height , pressure , tangentialPressure , tiltX , tiltY , twist , altitudeAngle , azimuthAngle , with buttons buttons depressed in accordance with the requirements of [ UI-EVENTS ] and [ POINTER-EVENTS ]. The generated events must set ctrlKey , shiftKey , altKey , and metaKey from the calculated global key state . Type specific properties for the pointer that are not exposed through the webdriver API must be set to the default value specified for hardware that doesn’t support that property.

  18. Return Return success with data null .

When required to To dispatch a pointerUp action given session, source id , action object , input state and tick duration a remote end must run the following steps:

  1. Let pointerType be equal to action object ’s pointerType property.

  2. Let button be equal to action object ’s button property.

  3. If the input state ’s pressed property does not contain button , return success with data null .

  4. Let x be equal to input state ’s x property.

  5. Let y be equal to input state ’s y property.

  6. Remove button from the set corresponding to input state ’s pressed property, and let buttons be the resulting value of that property.

  7. Perform implementation-specific action dispatch steps equivalent to releasing the button numbered button on the pointer of ID source id having type pointerType at viewport x coordinate x , viewport y coordinate y , with buttons buttons depressed, in accordance with the requirements of [ UI-EVENTS ] and [ POINTER-EVENTS ]. The generated events must set ctrlKey , shiftKey , altKey , and metaKey from the calculated global key state . Type specific properties for the pointer that are not exposed through the webdriver API must be set to the default value specified for hardware that doesn’t support that property.

  8. Return Return success with data null .

When required to To dispatch a pointerMove action given session , source id , action object , input state and tick duration a remote end must run the following steps:

  1. Let x offset be equal to the x property of action object .

  2. Let y offset be equal to the y property of action object .

  3. Let start x be equal to the x property of input state .

  4. Let start y be equal to the y property of input state .

  5. Let origin be equal to the origin property of action object .

  6. Run the substeps of the first matching value of origin :

    " viewport "

    Let x equal x offset and y equal y offset .

    " pointer "

    Let x equal start x + x offset and y equal start y + y offset .

    An object that represents a web element
    1. Let element be equal to the result of trying to get a known connected element with argument origin .

    2. Let x element and y element be the result of calculating the in-view center point of element .

    3. Let x equal x element + x offset , and y equal y element + y offset .

  7. If x is less than 0 or greater than the width of the viewport in CSS pixels , then return error with error code move target out of bounds .

  8. If y is less than 0 or greater than the height of the viewport in CSS pixels , then return error with error code move target out of bounds .

  9. Let duration be equal to action object ’s duration property if it is not undefined , or tick duration otherwise.

  10. If duration is greater than 0 and inside any implementation-defined bounds, asynchronously wait for an implementation defined amount of time to pass.

  11. Let width be equal to action object ’s width property.

  12. Let height be equal to action object ’s height property.

  13. Let pressure be equal to action object ’s pressure property.

  14. Let tangentialPressure be equal to action object ’s tangentialPressure property.

  15. Let tiltX be equal to action object ’s tiltX property.

  16. Let tiltY be equal to action object ’s tiltY property.

  17. Let twist be equal to action object ’s twist property.

  18. Let altitudeAngle be equal to action object ’s altitudeAngle property.

  19. Let azimuthAngle be equal to action object ’s azimuthAngle property.

  20. Perform a pointer move with arguments source id , input state , duration , start x , start y , x , y , width , height , pressure , tangentialPressure , tiltX , tiltY , twist , altitudeAngle , azimuthAngle .

  21. Return Return success with data null .

When required to perform a pointer move with arguments source id , input state , duration , start x , start y , target x and target y , width , height , pressure , tangentialPressure , tiltX , tiltY , twist , altitudeAngle , azimuthAngle , an implementation must run the following steps:

  1. Let time delta be the time since the beginning of the current tick , measured in milliseconds on a monotonic clock.

  2. Let duration ratio be the ratio of time delta and duration , if duration is greater than 0, or 1 otherwise.

  3. If duration ratio is 1, or close enough to 1 that the implementation will not further subdivide the move action, let last be true. Otherwise let last be false .

  4. If last is true, let x equal target x and y equal target y .

    Otherwise let x equal an approximation to duration ratio × ( target x - start x ) + start x , and y equal an approximation to duration ratio × ( target y - start y ) + start y .

  5. Let current x equal the x property of input state .

  6. Let current y equal the y property of input state .

  7. If x is not equal to current x or y is not equal to current y , run the following steps:

    1. Let buttons be equal to input state’s buttons property.

    2. Perform implementation-specific action dispatch steps equivalent to moving the pointer with ID source id having type pointerType from viewport x coordinate current x , viewport y coordinate current y to viewport x coordinate x and viewport y coordinate y , width , height , pressure , tangentialPressure , tiltX , tiltY , twist , altitudeAngle , azimuthAngle , with buttons buttons depressed, in accordance with the requirements of [ UI-EVENTS ] and [ POINTER-EVENTS ]. The generated events must set ctrlKey , shiftKey , altKey , and metaKey from the calculated global key state . Type specific properties for the pointer that are not exposed through the WebDriver API must be set to the default value specified for hardware that doesn’t support that property. In the case where the pointerType is " pen " or " touch ", and buttons is empty, this may be a no-op. For a pointer of type " mouse " this will always produce events including at least a pointerMove event.

    3. Let input state ’s x property equal x and y property equal y .

  8. If last is true, return.

  9. Run the following substeps in parallel :

    Note
    1. Asynchronously wait for an implementation defined amount of time to pass.

    2. Perform a pointer move with arguments source id , input state , duration , start x , start y , target x , target y .

When required to To dispatch a pointerCancel action given session , source id , action object , input state and tick duration a remote end must run the following steps:

  1. Perform implementation-specific action dispatch steps equivalent to cancelling the any action of the pointer with ID source id having type pointerType , in accordance with the requirements of [ UI-EVENTS ] and [ POINTER-EVENTS ].

  2. Return Return success with data null .

15.4.4 Wheel actions

When required to To dispatch a scroll action given session , source id , action object , and tick duration a remote end must run the following steps:

  1. Let x offset be equal to the x property of action object .

  2. Let y offset be equal to the y property of action object .

  3. Let origin be equal to the origin property of action object .

  4. Run the substeps of the first matching value of origin :

    " viewport "

    Let x equal x offset and y equal y offset .

    An object that represents a web element
    1. Let element be equal to the result of trying to get a known connected element with argument origin .

    2. Let x element and y element be the result of calculating the in-view center point of element .

    3. Let x equal x element + x offset , and y equal y element + y offset .

  5. If x is less than 0 or greater than the width of the viewport in CSS pixels , then return error with error code move target out of bounds .

  6. If y is less than 0 or greater than the height of the viewport in CSS pixels , then return error with error code move target out of bounds .

  7. Let delta x be equal to the deltaX property of action object .

  8. Let delta y be equal to the deltaY property of action object .

  9. Let duration be equal to action object ’s duration property if it is not undefined , or tick duration otherwise.

  10. If duration is greater than 0 and inside any implementation-defined bounds, asynchronously wait for an implementation defined amount of time to pass.

  11. Perform a scroll with arguments source id , duration , x , y , delta x , delta y , 0 , 0 .

  12. Return Return success with data null .

When required to perform a scroll with arguments source id , duration , x , y , target delta x , target delta y , current delta x and current delta y , an implementation must run the following steps:

  1. Let time delta be the time since the beginning of the current tick , measured in milliseconds on a monotonic clock.

  2. Let duration ratio be the ratio of time delta and duration , if duration is greater than 0, or 1 otherwise.

  3. If duration ratio is 1, or close enough to 1 that the implementation will not further subdivide the move action, let last be true. Otherwise let last be false .

  4. If last is true, let delta x equal target delta x - current delta x and delta y equal target delta y - current delta y .

    Otherwise let delta x equal an approximation to duration ratio × target delta x - current delta x , and delta y equal an approximation to duration ratio × target delta y - current delta y .

  5. If delta x is not equal to 0 or delta y is not equal to 0 , run the following steps:

    1. Perform implementation-specific action dispatch steps equivalent to wheel scroll with ID source id at viewport x coordinate x , viewport y coordinate y , deltaX value delta x , deltaY value delta y , in accordance with the requirements of [ UI-EVENTS ].

    2. Let current delta x property equal delta x + current delta x and current delta y property equal delta y + current delta y .

  6. If last is true, return.

  7. Run the following substeps in parallel :

    Note
    1. Asynchronously wait for an implementation defined amount of time to pass.

    2. Perform a scroll with arguments source id , duration , x , y , target delta x , target delta y , current delta x , current delta y .

15.5 Perform Actions

HTTP Method URI Template
POST /session/{ session id }/actions

The remote end steps , given session , URL variables and parameters are:

  1. Let actions by tick be the result of trying to extract an action sequence with argument parameters .

  2. If the If session 's current browsing context is no longer open , return error with error code no such window .

  3. Handle any user prompts error error Try to handle any user prompts with session .

  4. Dispatch actions with session and actions by tick . If this results in an error return that error.

  5. Return Return success with data null .

15.6 Release Actions

HTTP Method URI Template
DELETE /session/{ session id }/actions }/actions
Note

The Release Actions command is used to release all the keys and pointer buttons that are currently depressed. This causes events to be fired as if the state was released by an explicit series of actions. It also clears all the internal state of the virtual devices.

The remote end steps , given session , URL variables and parameters are:

  1. If the If session 's current browsing context is no longer open , return error with error code no such window .

  2. Let undo actions current session be equal to the session ’s input cancel list in reverse order.

  3. Dispatch tick actions with session , undo actions and duration 0.

  4. Let the current session Set session ’s input cancel list to an empty List .

  5. Let the current session Set session ’s input state table to an empty map.

  6. Let the current session Set session ’s active input sources to an empty list .

  7. Return Return success with data null .

16. User prompts

This chapter describes interaction with various types of user prompts . The common denominator for user prompts is that they are modal windows requiring users to interact with them before the event loop is unpaused and control is returned to session 's current top-level browsing context .

By default user prompts are not handled automatically unless a user prompt handler has been defined. When a user prompt appears, it is the task of the subsequent command to handle it. If the subsequent requested command is not one listed in this chapter, an unexpected alert open error will be returned.

User prompts that are spawned from beforeunload event handlers, are dismissed implicitly upon navigation or close window , regardless of the defined user prompt handler .

A user prompt has an associated user prompt message that is the string message shown to the user, or null if the message length is 0 .

The following table of simple dialogs enumerates all supported simple dialogs , along with the commands that are allowed to interact with it as a non-normative reference:

Definition Dialog Interactions
Alert window. alert Accept Alert
Dismiss Alert
Get Alert Text
Confirm window. confirm Dismiss Alert
Accept Alert
Get Alert Text
Prompt window. prompt Dismiss Alert
Accept Alert
Get Alert Text
Send Alert Text

The current user prompt is said to be the active user prompt , which can be one of the entries on the table of simple dialogs .

To dismiss the current user prompt , do so as if the user would click the Cancel or OK button, whichever is present, in that order.

To accept the current user prompt , do so as if the user would click the OK button.

The user prompt handler defines what action the remote end must take when a user prompt is encountered. This is defined by the unhandled prompt behavior capability. The following known prompt handling approaches table lists the keywords and states for the attribute:

Keyword State Description
" dismiss " Dismiss state All simple dialogs encountered should be dismissed .
" accept " Accept state All simple dialogs encountered should be accepted .
" dismiss and notify " Dismiss and notify state All simple dialogs encountered should be dismissed , and an error returned that the dialog was handled.
" accept and notify " Accept and notify state All simple dialogs encountered should be accepted , and an error returned that the dialog was handled.
" ignore " Ignore state All simple dialogs encountered should be left to the user to handle.

When required to deserialize as an unhandled prompt behavior an argument value :

  1. If value is not a string return an error with error code invalid argument .

  2. If value is not present as a keyword in the known prompt handling approaches table return an error with error code invalid argument .

  3. Return Return success with data value .

An annotated unexpected alert open error is an error with error code unexpected alert open and an optional error data dictionary with the following entries:

" text "
The current user prompt ’s message .

In order to To handle any user prompts given session , remote end must:

  1. If there is no current user prompt , abort these steps and return success .

  2. current session

    Perform the following substeps based on the session ’s user prompt handler :

    dismiss state

    Dismiss the current user prompt .

    accept state

    Accept the current user prompt .

    dismiss and notify state
    1. Dismiss the current user prompt .

    2. Return an annotated unexpected alert open error .

    accept and notify state
    1. Accept the current user prompt .

    2. Return an annotated unexpected alert open error .

    ignore state

    Return an annotated unexpected alert open error .

  3. Return Return success .

16.1 Dismiss Alert

HTTP Method URI Template
POST /session/{ session id }/alert/dismiss
Note

The Dismiss Alert command dismisses a simple dialog if present . A request to dismiss an alert user prompt , which may not necessarily have a dismiss button, has the same effect as accepting it.

The remote end steps , given session , URL variables and parameters are:

  1. If the If session 's current top-level browsing context is no longer open , return error with error code no such window .

  2. If there is no current user prompt , return error with error code no such alert .

  3. Dismiss the current user prompt .

  4. Return Return success with data null .

16.2 Accept Alert

HTTP Method URI Template
POST /session/{ session id }/alert/accept

The remote end steps , given session , URL variables and parameters are:

  1. If the If session 's current top-level browsing context is no longer open , return error with error code no such window .

  2. If there is no current user prompt , return error with error code no such alert .

  3. Accept the current user prompt .

  4. Return Return success with data null .

16.3 Get Alert Text

HTTP Method URI Template
GET /session/{ session id }/alert/text

The remote end steps , given session , URL variables and parameters are:

  1. If the If session 's current top-level browsing context is no longer open , return error with error code no such window .

  2. If there is no current user prompt , return error with error code no such alert .

  3. Let message be the text message associated with the current user prompt , or otherwise be null .

  4. Return Return success with data message .

16.4 Send Alert Text

HTTP Method URI Template
POST /session/{ session id }/alert/text
Note

The Send Alert Text command sets the text field of a window. prompt user prompt to the given value.

The remote end steps , given session , URL variables and parameters are:

  1. Let text be the result of getting the property " text " from parameters .

  2. If text is not a String , return error with error code invalid argument .

  3. If the If session 's current top-level browsing context is no longer open , return error with error code no such window .

  4. If there is no current user prompt , return error with error code no such alert .

  5. Run the substeps of the first matching current user prompt :

    alert
    confirm

    Return Return error with error code element not interactable .

    prompt

    Do nothing.

    Otherwise

    Return Return error with error code unsupported operation .

  6. Perform user agent dependent steps to set the value of current user prompt ’s text field to text .

  7. Return Return success with data null .

17. Screen capture

Screenshots are a mechanism for providing additional visual diagnostic information. They work by dumping a snapshot of the initial viewport ’s framebuffer as a lossless PNG image. It is returned to the local end as a Base64 encoded string.

WebDriver provides the Take Screenshot command to capture the top-level browsing context ’s initial viewport , and a command Take Element Screenshot for doing the same with the visible region of an element ’s bounding rectangle after it has been scrolled into view .

In order to draw a bounding box from the framebuffer , given a rectangle :

  1. If either the initial viewport ’s width or height is 0 CSS pixels , return error with error code unable to capture screen .

  2. Let paint width be the initial viewport ’s width – min ( rectangle x coordinate , rectangle x coordinate + rectangle width dimension ).

  3. Let paint height be the initial viewport ’s height – min ( rectangle y coordinate , rectangle y coordinate + rectangle height dimension ).

  4. Let canvas be a new canvas element, and set its width and height to paint width and paint height , respectively.

  5. Let context , a canvas context mode , be the result of invoking the 2D context creation algorithm given canvas as the target.

  6. Complete implementation specific steps equivalent to drawing the region of the framebuffer specified by the following coordinates onto context :

    X coordinate
    rectangle x coordinate
    Y coordinate
    rectangle y coordinate
    Width
    paint width
    Height
    paint height
  7. Return Return success with canvas .

To encode a canvas as Base64 a canvas element :

  1. If the canvas element’s bitmap’s origin-clean flag is set to false, return error with error code unable to capture screen .

  2. If the canvas element’s bitmap has no pixels (i.e. either its horizontal dimension or vertical dimension is zero) then return error with error code unable to capture screen .

  3. Let file be a serialization of the canvas element’s bitmap as a file , using " image/png " as an argument.

  4. Let data url data URL be a data: URL representing file . [ RFC2397 ]

  5. Let index be the index of " , " in data url data URL .

  6. Let encoded string be a substring of data url data URL using ( index + 1) as the start argument.

  7. Return Return success with data encoded string .

17.1 Take Screenshot

HTTP Method URI Template
GET /session/{ session id }/screenshot

The remote end steps , given session , URL variables and parameters are:

  1. If the If session 's current top-level browsing context is no longer open , return error with error code no such window .

  2. When the user agent is next to run the animation frame callbacks :

    1. Let root rect be session 's current top-level browsing context ’s document element ’s rectangle .

    2. Let screenshot result be the result of trying to call draw a bounding box from the framebuffer , given root rect as an argument.

    3. Let canvas be a canvas element of screenshot result ’s data.

    4. Let encoding result be the result of trying encoding a canvas as Base64 canvas .

    5. Let encoded string be encoding result ’s data.

  3. Return Return success with data encoded string .

17.2 Take Element Screenshot

HTTP Method URI Template
GET /session/{ session id }/element/{ element id }/screenshot }/screenshot
Note

The Take Element Screenshot command takes a screenshot of the visible region encompassed by the bounding rectangle of an element .

The remote end steps , given session , URL variables and parameters are:

  1. If the If the current browsing context is no longer open , return error with error code no such window .

  2. Handle any user prompts error Try to handle any user prompts with session .

  3. Let element be the result of trying to get a known connected element url variable element id with URL variables ' element id.

  4. Scroll into view the element .

  5. When the user agent is next to run the animation frame callbacks :

    1. Let element rect be element ’s rectangle .

    2. Let screenshot result be the result of trying to call draw a bounding box from the framebuffer , given element rect as an argument.

    3. Let canvas be a canvas element of screenshot result ’s data.

    4. Let encoding result be the result of trying encoding a canvas as Base64 canvas .

    5. Let encoded string be encoding result ’s data.

  6. Return Return success with data encoded string .

18. Print

The print functions are a mechanism to render the document to a paginated format. It is returned to the local end as a Base64 encoded string containing a PDF representation of the paginated document.

When required to parse a page range with arguments pageRanges and totalPages , an implementation must:

  1. Let pages be an empty Set
  2. For each range in pageRanges , run the following steps:
    1. If range is not either a Number or a String , return error with error code invalid argument .
    2. If range is a Number :

      1. If range is not an integer or is less than 0, return error with error code invalid argument
      2. Append range to pages

      Otherwise:

      1. Let rangeParts be the result of splitting range on a " - " character.
      2. If rangeParts has fewer than 1 or more than 2 elements, return error with error code invalid argument .
      3. If rangeParts has one element, append the result of If rangeParts has one element, append the result of trying to parse as an integer the first element of rangeParts to pages .

        Otherwise:

        1. If the first element of rangeParts is equivalent to an empty string , let lowerBound be 1 . Otherwise let lowerBound be the result of trying to parse as an integer the first element of rangeParts .
        2. If the second element of rangeParts is equivalent to an empty string let upperBound be totalPages . Otherwise let upperBound be the result of trying to parse as an integer the second element of rangeParts .
        3. If lowerBound is greater than upperBound , return error with error code invalid argument .
        4. Append all integers in the inclusive range lowerBound to upperBound to pages
    3. Return Return success with data pages .

A String is equivalent to an empty string if it has zero length after removing all whitespace characters.

When required to parse as an integer with argument input an implementation must:

  1. Let stripped be the result of stripping all leading and trailing whitespace characters from input .
  2. If stripped has zero length, return error with status invalid argument .
  3. If stripped contains any characters outside the range U+0030 - U+0039 (i.e. 0 - 9) inclusive, return error with status invalid argument .
  4. Let output be the result of calling parseInt with string stripped and radix 10 .
  5. Return Return success with data output .

A. Privacy

It is advisable that remote ends create a new profile when creating a new session . This prevents potentially sensitive session data from being accessible to new sessions , ensuring both privacy and preventing state from bleeding through to the next session.

B. Security

A user agent can rely on a command-line flag or a configuration option to test whether to enable WebDriver, or alternatively make the user agent initiate or confirm the connection through a privileged content document or control widget, in case the user agent does not directly implement the HTTP endpoints.

It is strongly suggested that user agents require users to take explicit action to enable WebDriver, and that WebDriver remains disabled in publicly consumed versions of the user agent.

To prevent arbitrary machines on the network from connecting and creating To prevent arbitrary machines on the network from connecting and creating sessions , it is suggested that only connections from loopback devices are allowed by default.

The The remote end can include a configuration option to limit the accepted IP range allowed to connect and make requests. The default setting for this might be to limit connections to the IPv4 localhost CIDR range 127.0.0.0/8 and the IPv6 localhost address ::1 . [ RFC4632 ]

It is also suggested that user agents make an effort to visually distinguish a user agent session that is under control of WebDriver from those used for normal browsing sessions. This can be done through a browser chrome element such as a “door hanger”, colorful decoration of the OS window, or some widget element that is prevalent in the window so that it easy to identify automation windows.

C. Element displayedness

Although WebDriver does not define a primitive to ascertain the visibility of an element in the viewport , we acknowledge that it is an important feature for many users. Here we include a recommended approach which will give a simplified approximation of an element ’s visibility, but please note that it relies only on tree-traversal, and only covers a subset of visibility checks.

The visibility of an element is guided by what is perceptually visible to the human eye. In this context, an element ’s displayedness does not relate to the visibility or display style properties.

The approach recommended to implementors to ascertain an element ’s visibility was originally developed by the Selenium project, and is based on crude approximations about an element 's nature and relationship in the tree. An element is in general to be considered visible if any part of it is drawn on the canvas within the boundaries of the viewport.

The element displayed algorithm is a boolean state where true signifies that the element is displayed and false signifies that the element is not displayed. To compute the state on element , invoke the Call ( bot.dom.isShown , null , element ). If doing so does not produce an error, return the return value from this function call. Otherwise return an ). If doing so does not produce an error, return the return value from this function call. Otherwise return an error with error code unknown error .

This function is typically exposed to GET requests with a URI Template of /session/{session id}/element/{element id}/displayed .

D. Acknowledgements

There have been a lot of people that have helped make browser automation possible over the years and thereby furthered the goals of this standard. In particular, thanks goes to the Selenium Open Source community, without which this standard would never have been possible.

This standard is authored by Aleksey Chemakin, Andreas Tolfsen , Andrey Botalov, Brian Burg, Christian Bromann, Clayton Martin, Daniel Wagner-Hall, David Burns , Dominique Hazael-Massieux, Eran Messeri, Erik Wilde, Gábor Csárdi, Henrik Skupin, James Graham, Jason Juang, Jason Leyba, Jim Evans, John Chen, John Jansen, Jonathan Lipps, Jonathon Kereliuk, Luke Inman-Semerau, Maja Frydrychowicz , Malini Das, Manoj Kumar, Marc Fisher, Mike Pennisi, Ondřej Machulda, Randall Kent, Sam Sneddon, Seva Lotoshnikov, Simon Stewart , Sri Harsha, Titus Fortner, and Vangelis Katsikaros. The work is coordinated and edited by David Burns and Simon Stewart .

Thanks to Berge Schwebs Bjørlo, Lukas Tetzlaff, Malcolm Rowe, Michael[tm] Smith, Nathan Bloomfield, Philippe Le Hégaret, Robin Berjon, Ross Patterson, and Wilhelm Joys Andersen for proofreading and suggesting areas for improvement.

E. Index

This specification relies on several other underlying specifications.

ARIA and related specifications

The following terms are defined in the Accessible Rich Internet Applications (WAI-ARIA) 1.2 specification: [ wai-aria-1.2 ]

The following terms are defined in the Accessible Name and Description Computation 1.1 specification: [ accname-1.1 ]

Web App Security

The following terms are defined in the Content Security Policy Level 3 specification: [ CSP3 ]

Base16, Base32, and Base64 Data Encodings

The following terms are defined in The Base16, Base32, and Base64 Data Encodings specification: [ RFC4648 ]

DOM

The following terms are defined in the Document Object Model specification: [ DOM ]

The following attributes are defined in the Document Object Model specification: [ DOM ]

The following terms are defined in the DOM Parsing and Serialization specification: [ DOM-PARSING ]

The following attributes are defined in the UI Events specification: [ UI-EVENTS ]

The following attributes are defined in the UI Events Code specification: [ UIEVENTS-CODE ]

The following attributes are defined in the UI Events Code specification: [ UIEVENTS-KEY ]

ECMAScript

The following terms are defined in the ECMAScript Language Specification: [ ECMA-262 ]

This specification also presumes that you are able to call some of the internal methods from the ECMAScript Language Specification:
The ECMAScript Language Specification also defines the following types, values, and operations that are used throughout this specification:
Encoding

The following terms are defined in the WHATWG Encoding specification: [ ENCODING ]

Fetch

The following terms are defined in the WHATWG Fetch specification: [ FETCH ]

File

The following interfaces are defined in the W3C File API specification: [ FILEAPI ]

Fullscreen

The following terms are defined in the WHATWG Fullscreen specification: [ FULLSCREEN ]

HTML

The following terms are defined in the HTML specification: [ HTML ]

The HTML specification also defines a number of elements which this specification has special-cased behavior for:

The HTML specification also defines states of the input element :

The HTML specification also defines a range of different attributes:

The HTML Editing APIs specification defines the following terms: [ EDITING ]

The following events are also defined in the HTML specification:

The “data” URL scheme specification defines the following terms: [ RFC2397 ]

HTTP and related specifications

To be HTTP compliant , it is supposed that the implementation supports the relevant subsets of [ RFC7230 ], [ RFC7231 ], [ RFC7232 ], [ RFC7234 ], and [ RFC7235 ].

The following terms are defined in the Cookie specification: [ RFC6265 ]

The following terms are defined in the Same Site Cookie specification: [ RFC6265bis ]

The following terms are defined in the Hypertext Transfer Protocol (HTTP) Status Code Registry:

The following terms are defined in the Netscape Navigator Proxy Auto-Config File Format:

The specification uses URI Templates . [ URI-TEMPLATE ]

Interaction
The following terms are defined in the Page Visibility Specification [ PAGE-VISIBILITY ]
Selenium
The following functions are defined within the Selenium project, at revision 1721e627e3b5ab90a06e82df1b088a33a8d11c20 .
Styling
The following terms are defined in the CSS Values and Units Module Level 3 specification: [ CSS3-VALUES ]
The following properties are defined in the CSS Basic Box Model Level 3 specification: [ CSS3-BOX ]
The following terms are defined in the CSS Device Adaptation Module Level 1 specification: [ CSS-DEVICE-ADAPT ]
The following properties are defined in the CSS Display Module Level 3 specification: [ CSS3-DISPLAY ]
The following terms are defined in the Geometry Interfaces Module Level 1 specification: [ GEOMETRY-1 ]
The following terms are defined in the CSS Cascading and Inheritance Level 4 specification: [ CSS-CASCADE-4 ]
The following terms are defined in the CSS Object Model: [ CSSOM ]:
The following functions are defined in the CSSOM View Module: [ CSSOM-VIEW ]:
The following terms are defined in [ mediaqueries-4 ]:
SOCKS Proxy and related specification:

To be SOCKS Proxy and SOCKS authentication compliant, it is supposed that the implementation supports the relevant subsets of [ RFC1928 ] and [ RFC1929 ].

Unicode
The following terms are defined in the standard: [ Unicode ]
Unicode Standard Annex #29
The following terms are defined in the standard: [ UAX29 ]
Unicode Standard Annex #44
The following terms are defined in the standard: [ UAX44 ]
URLs
The following terms are defined in the WHATWG URL standard: [ URL ]
Web IDL

The IDL fragments in this specification must be interpreted as required for conforming IDL fragments, as described in the Web IDL specification. [ WEBIDL ]

Promises Guide

The following terms are defined in the Promises Guide. [ PROMISES-GUIDE ]

XML Namespaces

The following terms are defined in the Namespaces in XML [ XML-NAMES ]

XPATH

The following terms are defined in the Document Object Model XPath standard [ XPATH ]

E.1 Terms defined by this specification

E.2 Terms defined by reference

F. References

F.1 Normative references

[accname-1.1]
Accessible Name and Description Computation 1.1 . Joanmarie Diggs; Bryan Garaventa; Michael Cooper. W3C. 18 December 2018. W3C Recommendation. URL: https://www.w3.org/TR/accname-1.1/
[CSP3]
Content Security Policy Level 3 . Mike West. W3C. 29 June 2021. W3C Working Draft. URL: https://www.w3.org/TR/CSP3/
[CSS-CASCADE-4]
CSS Cascading and Inheritance Level 4 . Elika Etemad; Tab Atkins Jr.. W3C. 19 March 2021. W3C Working Draft. URL: https://www.w3.org/TR/css-cascade-4/
[CSS-DEVICE-ADAPT]
CSS Device Adaptation Module Level 1 . Rune Lillesveen; Florian Rivoal; Matt Rakow. W3C. 29 March 2016. W3C Working Draft. URL: https://www.w3.org/TR/css-device-adapt-1/
[CSS21]
Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification . Bert Bos; Tantek Çelik; Ian Hickson; Håkon Wium Lie. W3C. 7 June 2011. W3C Recommendation. URL: https://www.w3.org/TR/CSS21/
[CSS3-BOX]
CSS Box Model Module Level 3 . Elika Etemad. W3C. 22 December 2020. W3C Candidate Recommendation. URL: https://www.w3.org/TR/css-box-3/
[CSS3-DISPLAY]
CSS Display Module Level 3 . Tab Atkins Jr.; Elika Etemad. W3C. 3 September 2021. W3C Candidate Recommendation. URL: https://www.w3.org/TR/css-display-3/
[CSS3-VALUES]
CSS Values and Units Module Level 3 . Tab Atkins Jr.; Elika Etemad. W3C. 6 June 2019. W3C Candidate Recommendation. URL: https://www.w3.org/TR/css-values-3/
[CSSOM]
CSS Object Model (CSSOM) . Daniel Glazman; Emilio Cobos Álvarez. W3C. 26 August 2021. W3C Working Draft. URL: https://www.w3.org/TR/cssom-1/
[CSSOM-VIEW]
CSSOM View Module . Simon Pieters. W3C. 17 March 2016. W3C Working Draft. URL: https://www.w3.org/TR/cssom-view-1/
[DOM]
DOM Standard . Anne van Kesteren. WHATWG. Living Standard. URL: https://dom.spec.whatwg.org/
[DOM-PARSING]
DOM Parsing and Serialization . Travis Leithead. W3C. 17 May 2016. W3C Working Draft. URL: https://www.w3.org/TR/DOM-Parsing/
[ECMA-262]
ECMAScript Language Specification . Ecma International. URL: https://tc39.es/ecma262/multipage/
[EDITING]
HTML Editing APIs . A. Gregor. W3C. URL: https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html
[ENCODING]
Encoding Standard . Anne van Kesteren. WHATWG. Living Standard. URL: https://encoding.spec.whatwg.org/
[FETCH]
Fetch Standard . Anne van Kesteren. WHATWG. Living Standard. URL: https://fetch.spec.whatwg.org/
[FILEAPI]
File API . Marijn Kruisselbrink; Arun Ranganathan. W3C. 4 June 2021. W3C Working Draft. URL: https://www.w3.org/TR/FileAPI/
[FULLSCREEN]
Fullscreen API Standard . Philip Jägenstedt. WHATWG. Living Standard. URL: https://fullscreen.spec.whatwg.org/
[GEOMETRY-1]
Geometry Interfaces Module Level 1 . Simon Pieters; Chris Harrelson. W3C. 4 December 2018. W3C Candidate Recommendation. URL: https://www.w3.org/TR/geometry-1/
[HTML]
HTML Standard . Anne van Kesteren; Domenic Denicola; Ian Hickson; Philip Jägenstedt; Simon Pieters. WHATWG. Living Standard. URL: https://html.spec.whatwg.org/multipage/
[infra]
Infra Standard . Anne van Kesteren; Domenic Denicola. WHATWG. Living Standard. URL: https://infra.spec.whatwg.org/
[mediaqueries-4]
Media Queries Level 4 . Florian Rivoal; Tab Atkins Jr.. W3C. 21 July 2020. W3C Candidate Recommendation. URL: https://www.w3.org/TR/mediaqueries-4/
[PAGE-VISIBILITY]
Page Visibility (Second Edition) . Jatinder Mann; Arvind Jain. W3C. 29 October 2013. W3C Recommendation. URL: https://www.w3.org/TR/page-visibility/
[POINTER-EVENTS]
Pointer Events . Jacob Rossi; Matt Brubeck. W3C. 4 April 2019. W3C Recommendation. URL: https://www.w3.org/TR/pointerevents/
[PROMISES-GUIDE]
Writing Promise-Using Specifications . Domenic Denicola. W3C. 9 November 2018. TAG Finding. URL: https://www.w3.org/2001/tag/doc/promises-guide
[RFC1928]
SOCKS Protocol Version 5 . M. Leech; M. Ganis; Y. Lee; R. Kuris; D. Koblas; L. Jones. IETF. March 1996. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc1928
[RFC1929]
Username/Password Authentication for SOCKS V5 . M. Leech. IETF. March 1996. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc1929
[RFC2397]
The "data" URL scheme . L. Masinter. IETF. August 1998. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc2397
[RFC3514]
The Security Flag in the IPv4 Header . S. Bellovin. IETF. 1 April 2003. Informational. URL: https://www.rfc-editor.org/rfc/rfc3514
[RFC4122]
A Universally Unique IDentifier (UUID) URN Namespace . P. Leach; M. Mealling; R. Salz. IETF. July 2005. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc4122
[RFC4632]
Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan . V. Fuller; T. Li. IETF. August 2006. Best Current Practice. URL: https://www.rfc-editor.org/rfc/rfc4632
[RFC4648]
The Base16, Base32, and Base64 Data Encodings . S. Josefsson. IETF. October 2006. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc4648
[RFC6265]
HTTP State Management Mechanism . A. Barth. IETF. April 2011. Proposed Standard. URL: https://httpwg.org/specs/rfc6265.html
[RFC6265bis]
Cookies: HTTP State Management Mechanism . M. West; J. Wilander. IETF. Draft. URL: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-05
[RFC7230]
Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing . R. Fielding, Ed.; J. Reschke, Ed.. IETF. June 2014. Proposed Standard. URL: https://httpwg.org/specs/rfc7230.html
[RFC7231]
Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content . R. Fielding, Ed.; J. Reschke, Ed.. IETF. June 2014. Proposed Standard. URL: https://httpwg.org/specs/rfc7231.html
[RFC7232]
Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests . R. Fielding, Ed.; J. Reschke, Ed.. IETF. June 2014. Proposed Standard. URL: https://httpwg.org/specs/rfc7232.html
[RFC7234]
Hypertext Transfer Protocol (HTTP/1.1): Caching . R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. IETF. June 2014. Proposed Standard. URL: https://httpwg.org/specs/rfc7234.html
[RFC7235]
Hypertext Transfer Protocol (HTTP/1.1): Authentication . R. Fielding, Ed.; J. Reschke, Ed.. IETF. June 2014. Proposed Standard. URL: https://httpwg.org/specs/rfc7235.html
[UAX29]
Unicode Text Segmentation . Mark Davis; Christopher Chapman. Unicode Consortium. 24 August 2021. Unicode Standard Annex #29. URL: https://www.unicode.org/reports/tr29/tr29-39.html
[UAX44]
Unicode Character Database . Ken Whistler; Laurențiu Iancu. Unicode Consortium. 30 August 2021. Unicode Standard Annex #44. URL: https://www.unicode.org/reports/tr44/tr44-28.html
[UI-EVENTS]
UI Events . Gary Kacmarcik; Travis Leithead; Doug Schepers. W3C. 30 May 2019. W3C Working Draft. URL: https://www.w3.org/TR/uievents/
[UIEVENTS-CODE]
UI Events KeyboardEvent code Values . Gary Kacmarcik; Travis Leithead. W3C. 1 June 2017. W3C Candidate Recommendation. URL: https://www.w3.org/TR/uievents-code/
[UIEVENTS-KEY]
UI Events KeyboardEvent key Values . Gary Kacmarcik; Travis Leithead. W3C. 1 June 2017. W3C Candidate Recommendation. URL: https://www.w3.org/TR/uievents-key/
[Unicode]
The Unicode Standard . Unicode Consortium. URL: https://www.unicode.org/versions/latest/
[URI-TEMPLATE]
URI Template . J. Gregorio; R. Fielding; M. Hadley; M. Nottingham; D. Orchard. IETF. March 2012. Proposed Standard. URL: https://www.rfc-editor.org/rfc/rfc6570
[URL]
URL Standard . Anne van Kesteren. WHATWG. Living Standard. URL: https://url.spec.whatwg.org/
[wai-aria-1.2]
Accessible Rich Internet Applications (WAI-ARIA) 1.2 . Joanmarie Diggs; James Nurthen; Michael Cooper. W3C. 2 March 2021. W3C Candidate Recommendation. URL: https://www.w3.org/TR/wai-aria-1.2/
[WEBIDL]
Web IDL . Boris Zbarsky. W3C. 15 December 2016. W3C Editor's Draft. URL: https://heycam.github.io/webidl/
[XML-NAMES]
Namespaces in XML 1.0 (Third Edition) . Tim Bray; Dave Hollander; Andrew Layman; Richard Tobin; Henry Thompson et al. W3C. 8 December 2009. W3C Recommendation. URL: https://www.w3.org/TR/xml-names/
[XPATH]
XML Path Language (XPath) Version 1.0 . James Clark; Steven DeRose. W3C. 16 November 1999. W3C Recommendation. URL: https://www.w3.org/TR/xpath-10/
Permalink Referenced in: § 6.3 Processing model § 12.3.4 Find Element From Element § 12.3.5 Find Elements From Element § 12.3.6 Find Element From Shadow Root § 12.3.7 Find Elements From Shadow Root § 12.3.9 Get Element Shadow Root § 12.4.1 Is Element Selected § 12.4.2 Get Element Attribute § 12.4.3 Get Element Property § 12.4.4 Get Element CSS Value (2) § 12.4.5 Get Element Text § 12.4.6 Get Element Tag Name § 12.4.7 Get Element Rect § 12.4.8 Is Element Enabled § 12.4.9 Get Computed Role § 12.4.10 Get Computed Label § 12.5.3 Element Send Keys § 14.2 Get Named Cookie § 14.4 Delete Cookie § 17.2 Take Element Screenshot