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] Expose browserContext.on('pageerror') for capturing exceptions #24466

Closed
vigneshshanmugam opened this issue Jul 27, 2023 · 1 comment · Fixed by #24452
Closed

[Feature] Expose browserContext.on('pageerror') for capturing exceptions #24466

vigneshshanmugam opened this issue Jul 27, 2023 · 1 comment · Fixed by #24452
Assignees
Labels
open-to-a-pull-request The feature request looks good, we are open to reviewing a PR v1.38

Comments

@vigneshshanmugam
Copy link
Contributor

Currently when page issues requests, we can use the pageerror event on the page to capture the unhandled exceptions that happen on that given page. But if the page opens a new popup or window, we would have to manually listen to these pageerror on those next set of pages to be able to capture these exceptions.

In an ideal scenario, It would be better to expose this information via the BrowserContext which would hold all the Unhandled exceptions that happen on the pages that are created within this context.

const context = await browser.newContext();

context.on("pageerror", (error, page?) => {
   // error -> unhandled exception
});

It also sync with other API's like the context.on("error", (error) => {}) where we can log all the error's that happen on all the pages created by this context.

@pavelfeldman
Copy link
Member

I'm supportive of the idea, will look at the patch, thanks!

@aslushnikov aslushnikov added v1.38 and removed v1.37 labels Jul 31, 2023
@aslushnikov aslushnikov added the open-to-a-pull-request The feature request looks good, we are open to reviewing a PR label Jul 31, 2023
yury-s pushed a commit that referenced this issue Aug 17, 2023
+ fix #24466
+ Adds support for exposing the `pageerror` events via `browserContext`
API.
+ Helps with capturing the overall exceptions that are thrown outside of
the the current page and also captures the exceptions happens on other
windows/popups.
+ Keeps the API in sync with `context.on('request)',
context.on('console'), etc..`
Germandrummer92 pushed a commit to OctoMind-dev/playwright that referenced this issue Oct 27, 2023
+ fix microsoft#24466
+ Adds support for exposing the `pageerror` events via `browserContext`
API.
+ Helps with capturing the overall exceptions that are thrown outside of
the the current page and also captures the exceptions happens on other
windows/popups.
+ Keeps the API in sync with `context.on('request)',
context.on('console'), etc..`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-to-a-pull-request The feature request looks good, we are open to reviewing a PR v1.38
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants