Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define on a shared user facing API for BiDi and CDP #8168

Closed
6 of 11 tasks
diemol opened this issue Apr 6, 2020 · 9 comments
Closed
6 of 11 tasks

Define on a shared user facing API for BiDi and CDP #8168

diemol opened this issue Apr 6, 2020 · 9 comments

Comments

@diemol
Copy link
Member

diemol commented Apr 6, 2020

🚀 Feature Proposal

We'd like to define a shared user-facing API that users can interact with when using bi-directional WebDriver API. Until the standard is delivered, this API is likely to be backed by CDP.

Motivation

See https://github.com/w3c/webdriver-bidi/blob/master/proposals/core.md for more details. The API should focus on satisfying the following use cases:

Event-based use cases:

  • Listen for DOM events
  • Log what's going on in the browser including console and JS errors
  • Fail fast on any JS error
  • Intercept network requests allowing to mock backend requests
  • Record traffic (Alex: Allow replaying it?)
  • Authenticate on secure pages
  • Bootstrap scripts (for example, execute JavaScript snippet on every page load)
  • Listen for new contexts (Alex: Not sure what do we mean by contexts?)

Other use cases:

  • Take full-page screenshots
  • Access throttling and performance timings
  • Dynamic changes to iframe or documents (Alex: Not sure it means to make changes or listen for changes?)

Example

Read the issue comments for examples.

@p0deje
Copy link
Member

p0deje commented May 19, 2020

A use-csae of CDP used API I have is to add JS snippet to be executed on every new page load. In current Ruby this is done in the following way:

driver.devtools.page.enable
driver.devtools.page.add_script_to_evaluate_on_new_document('my javascript code string')

I'm not sure how Selenium API for it might look like.

@shs96c
Copy link
Member

shs96c commented May 19, 2020

After discussion in the #selenium-tlc slack channel, the current suggestion is for me to put together some strawman APIs to feed the design process.

@p0deje
Copy link
Member

p0deje commented May 19, 2020

After discussion in the #selenium-tlc slack channel, the API will essentially be a user-facing API for WebDriver BiDi so we can draft based on its scenarios from https://github.com/w3c/webdriver/blob/master/webdriver-bidi/webdriver.md#goals:

  • Listen for DOM events
  • Log what's going on in the browser including console and JS errors
  • Fail fast on any JS error
  • Mock backends and intercept network requests
  • Record traffic
  • Full-page screenshot
  • Access to native devtools protocol
  • Dynamic changes to iframe or documents
  • Performance timings
  • Notifying of new contexts
  • Bootstrap scripts

I'll turn this list into a checklist and pin to the issue so that we can track the work.

@p0deje p0deje changed the title Define on a shared user facing API for CDP Define on a shared user facing API for BiDi (with CDP backend) May 19, 2020
@p0deje p0deje changed the title Define on a shared user facing API for BiDi (with CDP backend) Define on a shared user facing API for BiDi and CDP May 19, 2020
@shs96c shs96c self-assigned this May 29, 2020
@shs96c
Copy link
Member

shs96c commented Sep 8, 2020

Useful diffs for this:

Authentication: 6c198bc

Listen for page mutations: 65f0ae8

Listen out for console logs: 74f3b22

@shs96c
Copy link
Member

shs96c commented Sep 14, 2020

Listen out for js errors: d6c10c6

@shs96c
Copy link
Member

shs96c commented Sep 14, 2020

The following work remains on the Java bindings:

  • Expose "pin script" (possibly on the JavascriptExecutor)
  • Add a remote end point for "pin script"
  • Add interfaces via the Augmenter

@jimevans
Copy link
Member

jimevans commented Nov 6, 2020

One more use case (which is actually as subset of "intercept network requests," but current implementations do not do this): Get response information before page is displayed in the browser.

This is to solve for the "get the HTTP status code" use case. I will refrain from editorializing on the usefulness of this use case.

@titusfortner
Copy link
Member

Can I propose adding the use case of setting cookies on a domain you aren't on? I'd like to be able to authenticate a user with an API, and set the resulting token value in a cookie so I can navigate to a specific page. Right now I have to navigate to the domain first (which isn't always possible with domain redirects).

@shs96c
Copy link
Member

shs96c commented Mar 29, 2021

I think we now have these in all the language bindings. Closing.

We can always add more use-cases if we need to.

@shs96c shs96c closed this as completed Mar 29, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants