I'm trying to parse a page using puppeteer, one of the scripts on the page is overriding createElement property of the document object. It fails and throws the following exception:
Uncaught TypeError: Cannot assign to read only property 'createElement' of object '#<HTMLDocument>'
After some investigation it appears that document properties in puppeteer are protected by proxy objects.
When running document.createElement in the puppeteer console it evaluates to
Proxy {length: 1, name: "createElement"}
While doing the same in Chrome it evaluates to a normal function.
Is there a way to tell puppeteer to maintain the same behaviour as it is in Chrome and make the document object writable?
Edit:
Tried this, didn't work, document.createElement is still a Proxy.
await page.evaluateOnNewDocument(() => {
document.createElement = document.__proto__.createElement;
})