chrome dev console result and puppeteer result is different
See original GitHub issuewhen i was scrapping innerHTML using puppeteer, first test using chrome dev console
document.querySelector("div#c_food_tab1 div#mCSB_4_container").innerHTML;
is return good result so copy & paste this code to my src and run code
result is Error
(node:4895) UnhandledPromiseRejectionWarning: Error: Evaluation failed: TypeError: Cannot read property ‘innerHTML’ of null
so i decided to fix my code that HTML element select all course of target
const profRestaurant = await page.evaluate( () => document.querySelector("div#c_food_tab1 div#mCSB_5 div#mCSB_5_container") .innerHTML );
then code is working
i wondering about why their(chrome dev console, puppeteer) return different result
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Puppeteer vs Chrome console log different behaviour
First I check with Chrome inspect and console how to find the right value and it was everything ok. Then I paste the...
Read more >Debugging Puppeteer - Chrome Developers
# Use debugger in node.js ... This will let you debug test code. For example, you can step over await page.click() in the...
Read more >Using Chrome Devtools Protocol with Puppeteer
Puppeteer is a high level abstraction over the Chrome Devtools Protocol that gives you a user-friendly API to drive Chromium (or Blink) based...
Read more >Devtools Service - WebdriverIO
A WebdriverIO service that allows you to run Chrome DevTools commands in your tests ... The following commands with their results are available: ......
Read more >Playing with Puppeteer - Level Up Coding
I used the developer homepage and set the locale to en-US to ensure I will only get English results. Using the chrome developer...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The layout and DOM structure of the page depends on the viewport size. When you test on the common browser, the viewport is wide and the page has
"div#c_food_tab1 div#mCSB_4_container"
selector. Puppeteer sets an initial viewport size to 800px x 600px, so with puppeteer script the viewport is narrow and the page has"div#c_food_tab1 div#mCSB_5 div#mCSB_5_container"
instead of"div#c_food_tab1 div#mCSB_4_container"
. If you add this line in your first script, it will work properly (you can set any other wide size):@vsemozhetbyt Oh, viewport! wonderful thanks to your help!