Chrome Devtools Protocol with BiDi API
Usage
The following list of APIs will be growing as the Selenium project works through supporting real world use cases. If there is additional functionality you’d like to see, please raise a feature request.
As these examples are re-implemented with the WebDriver-Bidi protocol, they will be moved to the WebDriver Bidi pages.
Examples
Basic authentication
Some applications make use of browser authentication to secure pages. It used to be common to handle them in the URL, but browser stopped supporting this. With BiDi, you can now provide the credentials when necessary
Alternate implementations can be found at CDP Endpoint Basic Authentication and CDP API Basic Authentication
An alternate implementation may be found at CDP Endpoint Basic Authentication
Pin scripts
This can be especially useful when executing on a remote server. For example, whenever you check the visibility of an element, or whenever you use the classic get attribute method, Selenium is sending the contents of a js file to the script execution endpoint. These files are each about 50kB, which adds up.
Mutation observation
Mutation Observation is the ability to capture events via WebDriver BiDi when there are DOM mutations on a specific element in the DOM.
Console logs and errors
Listen to the console.log
events and register callbacks to process the event.
CDP API Console logs and WebDriver BiDi Console logs
Use the WebDriver BiDi Console logs implementation. HasLogEvents
will likely end up deprecated because it does not implement Closeable
.
JavaScript exceptions
Listen to the JS Exceptions and register callbacks to process the exception details.
Use the WebDriver BiDi JavaScript exceptions implementation
Network Interception
Both requests and responses can be recorded or transformed.