go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.
https://go-rod.github.io
MIT License
5.01k stars 328 forks source link

ElementX stuck if you specify a non-existent element #1002

Closed DimaRQ closed 5 months ago

DimaRQ commented 5 months ago

Sometimes there is no element on the site //*[text()='AGREE'], then the code gets stuck in the "ElementByJS" function, as far as I understand, it does not have a timeout

el, err := page.ElementX(xpath)

v0.114.5

github-actions[bot] commented 5 months ago

Please add a valid Rod Version: v0.0.0 to your issue. Current version is v0.114.5

generated by check-issue

ysmood commented 5 months ago

Please look at the word retries in its doc, I think it's clear:

https://github.com/go-rod/rod/blob/310be6f88d66d1465957e4bfd832619df3881d86/query.go#L152-L154

Also about timeout:

https://go-rod.github.io/#/context-and-timeout