Skip to content Skip to sidebar Skip to footer

Chrome Devtools Protocol: How To Unsubscribe Page.javascriptdialogopening Event

I am using the Chrome DevTools Protocol API functions to listen to the javascriptDialogOpening event. Below is the code. async navigate(url: URL, target: any) { const { Page } =

Solution 1:

By putting the javascriptDialogOpening event registration in the navigate handler, you are adding the handler over and over again. Because every time a navigation event happens, you are re-adding this event handler.

What you really want here is to put the javascriptDialogOpening event registration in your initialization code. If you do this, it will be registered only once and you will no longer have this issue.

CDP({'host': host, 'port': port}, (client) => {
// ...Page.javascriptDialogOpening((params) => {
      Page.handleJavaScriptDialog({'accept': true});
    });

Post a Comment for "Chrome Devtools Protocol: How To Unsubscribe Page.javascriptdialogopening Event"