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
.
As reported in #1668, page.click(selector)
doesn't work if page redefines window.Node
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;
}
} );
Any updates on this issue?
Most helpful comment
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: