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

[Feature] Browser event "context" #1678

Closed
jperl opened this issue Apr 6, 2020 · 3 comments
Closed

[Feature] Browser event "context" #1678

jperl opened this issue Apr 6, 2020 · 3 comments

Comments

@jperl
Copy link
Contributor

jperl commented Apr 6, 2020

Feature Request:

A browser event: 'context' emitted when a new context is created.

browser.on("context", (context) => context.addInitScript(...));

Our Use Case:

We use the browser context to capture logs and video artifacts.

Since there is no API to listen for new contexts, we require users to call qawolf.register(context) in their test code when they create a new context.

If we could listen for a context event we can manage this registration logic internally in our launch helper.

Other Use Cases:

This would be valuable to set up global init scripts and new page listeners.

@pavelfeldman
Copy link
Member

Node events are synchronous, so the suggested syntax implies a race between the qawolf set up and context usage. I actually like the qawolf.register option - it is explicit and can be awaited.

@jperl
Copy link
Contributor Author

jperl commented Apr 7, 2020

The setup for the artifacts in qawolf.register happens on the "page" event so qawolf.register does not need to be awaited.

The only thing that needs to be awaited is the html selector registration which we will probably move to qawolf.launch.

@pavelfeldman
Copy link
Member

Marking it as out of scope for Playwright driver, you should use CDP for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants