question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

evaluateOnNewDocument on all new pages

See original GitHub issue

Hello I am using the following piece of code to prevent websites from detecting puppeteer.

const page = await browser.newPage();

page.evaluateOnNewDocument(readFileSync("puppeteer-detection-bypass.js"));

The problem is that when I click on a link with the “target” attribute set to “_blank”. The browser opens a new tab and puppeteer is detected because the evaluateOnNewDocument is not set for this new page.

How can I handle the creation of new pages in order to set the evaluateOnNewDocument for all of them? Is there an event to listen? Is there a way to set evaluateOnNewDocument for all new pages?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aslushnikovcommented, Jun 6, 2019

@Vasile-Peste given that you re-opened this issue… Is there anything we (puppeteer team) can help you with?

1reaction
etscriptcommented, Jun 5, 2019

@Vasile-Peste The sincerity anticipates your reply !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page.evaluateOnNewDocument() method - Puppeteer
Adds a function which would be invoked in one of the following scenarios: ... The function is invoked after the document was created...
Read more >
evaluateOnNewDocument on all new pages #7399 - GitHub
Puppeteer version: 9.1.1 Platform / OS version: Mac (M1) URLs (if applicable): Node.js version: v15.14.0 What steps will reproduce the ...
Read more >
How to use evaluateOnNewDocument and exposeFunction?
On the other hand, page.evaluateOnNewDocument() evaluates a predefined function when a new document is created and before any of its scripts are executed....
Read more >
How to use evaluateOnNewDocument function in Page
Promise which resolves to a new Page object. Page.goto. Navigates to a URL. Browser.close. Closes browser with all the pages (if any were...
Read more >
Use evaluateOnNewDocument in Puppeteer With Examples
Learn how to use evaluateOnNewDocument function in Puppeteer framework for your next JavaScript automation project with LambdaTest Automation Testing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found