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

page.waitForSelector doesn't work on baidu.com #609

Closed
aslushnikov opened this issue Aug 30, 2017 · 3 comments
Closed

page.waitForSelector doesn't work on baidu.com #609

aslushnikov opened this issue Aug 30, 2017 · 3 comments
Labels
bug chromium Issues with Puppeteer-Chromium

Comments

@aslushnikov
Copy link
Contributor

The following script fails with baidu.com:

const puppeteer = require('puppeteer');
(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://baidu.com');
  await page.waitForSelector('div');
  browser.close();
})();

The reason is that Baidu nullifies MutationObserver that is required for waitForSelector.

@aslushnikov
Copy link
Contributor Author

As reported in #1668, page.click(selector) doesn't work if page redefines window.Node

@nylen
Copy link

nylen commented Dec 29, 2017

Suggest renaming this issue to something more general, like: "Puppeteer methods break if pages redefine built-in global objects"

Is this sort of thing even possible to work around at the library level? I did this in my code, which seems to work ok:

await this.page.evaluate( () => {
    if ( ! window.Node ) {
        window.Node = {};
    }
    if ( ! Node.ELEMENT_NODE ) {
        Node.ELEMENT_NODE = 1;
    }
} );

@klichukb
Copy link

Any updates on this issue?

@aslushnikov aslushnikov added the chromium Issues with Puppeteer-Chromium label Dec 6, 2018
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Jan 28, 2019
This patch starts executing frame.waitForSelector and frame.waitForXPath
in secondary world. As a result, websites that mutate page global
context (e.g. removing global MutationObserver) don't break Puppeteer's
behavior.

Fixes puppeteer#609
aslushnikov added a commit that referenced this issue Jan 28, 2019
…3856)

This patch starts executing frame.waitForSelector and frame.waitForXPath
in secondary world. As a result, websites that mutate page global
context (e.g. removing global MutationObserver) don't break Puppeteer's
behavior.

Fixes #609
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug chromium Issues with Puppeteer-Chromium
Projects
None yet
Development

No branches or pull requests

3 participants