Skip to content
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

Investigate use of sleep() after Selenium .get() call #12

Open
naclomi opened this issue Apr 1, 2022 · 0 comments
Open

Investigate use of sleep() after Selenium .get() call #12

naclomi opened this issue Apr 1, 2022 · 0 comments

Comments

@naclomi
Copy link

naclomi commented Apr 1, 2022

Looking here:
https://github.com/rafrisci/sports-book-manager/blob/master/sports_book_manager/book_scrape_class.py#L263

Is the timer.sleep(10) necessary? From selenium documentation:

https://selenium-python.readthedocs.io/getting-started.html#example-explained

The driver.get method will navigate to a page given by the URL. WebDriver will wait until the page has fully loaded (that is, the “onload” event has fired) before returning control to your test or script. Be aware that if your page uses a lot of AJAX on load then WebDriver may not know when it has completely loaded:

If the latter case is throwing a spanner in the works, that is that things have to "happen" on the page after it initially loads before your data shows up, I strongly suggest using Selenium's WebDriverWait to block until the elements you care about on the page exist. Check this link out for a discussion on how to do that:

https://stackoverflow.com/questions/59130200/selenium-wait-until-element-is-present-visible-and-interactable

In my experience, relying on calibrated sleep() calls almost always break eventually and when they're in my code I wake up throughout the night in cold sweats o_o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant