-
Notifications
You must be signed in to change notification settings - Fork 773
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
chromedp does not load whole page if the page contains too many javascript-generated elements #304
Comments
Is the element you're looking for inside an iframe, by any chance? If so, this is a duplicate of #72, as we lack proper support for iframes currently. |
I have the same issue. And no, there is no one iframe on a page. |
You have the same issue with the same page? If not, please post a program to reproduce your problem. |
go.mod
First of all, i checked code snippet of @dynahcatq got the same result. My code snippet:
Output
If I decrease timeout to 10 seconds then I get the correct result in the second iteration. |
@mvdan I believe that the element (
|
Thanks all for the details. I'll have a proper look soon. |
I have the same problem too. |
I had a look, and this is definitely one weird page. It navigates to five frames in total, which seems to trigger some sort of race which results in chromedp never loading the nodes you're after. I'm not a JS expert, and it doesn't help that the page is very slow to load and has lots of obfuscated JS code. If anyone can reproduce this with a single short HTML file, that would be very appreciated and speed up my debugging. |
Ok, after an exhaustive amount of debugging, I finally figured out what's the problem. It is related to child frames (like iframes) after all, but not in the way I was initially suspecting. The issue is that the page loads a number of child frames before the top frame has finished loading its nodes. chromedp was incorrectly seeing the child frames as the new top-level frames, so the original frame was left behind and we never saw its interesting nodes. The fix is simple, all the tests pass (including a regression test for this case), so I see no reason to not include this into v0.2.0. Thanks all for the patience. Also, to clarify - this fix is somewhat related to #72, in that it's a required step to have iframes work well, but it's not a full fix for that issue. |
Can confirm. I spent days debugging and only get to the racing part, but have no idea what was causing the race. Really appreciate your effort and the fix @mvdan. |
What versions are you running?
What did you do?
When trying to navigate to a page that generate a lot of elements using javascript, it is very likely (see further analysis) that chromedp cannot see the generated elements. Here is an example code:
The code simply navigate to https://streamelements.com/shanksy/store and wait for any
md-card
element to be ready then get text.What did you expect to see?
Helios Prime SwitchdescriptionMR8 Helios Prime Switch MR8 Helios Prime Switchshopping_basket 4 items leftmonetization_on20000 chat!redeem helios_prime_switchRedeem item
(The first item currently for sell on the website)What did you see instead?
Further analysis
Being doing more test on this and the results are listed below:
bash i=0 && while ! go run fetch.go; do sleep 1 && (( ++i )) && echo $i; done
By the way I do not have chromium installed, so I guess the chromedp was running on my google chrome browser.
The text was updated successfully, but these errors were encountered: