Wait for a page to load with Python selenium. In this article you’ll learn how to do that. It’s a bit counter-intuitive.
Selenium lets you automate the browser, but you don’t need time.sleep to wait for the page loading to complete. In fact, it works differently than you may expect.
Related course:
example
selenium wait for page to load
The code block below shows you how to wait for a page load to complete. It uses a timeout. It waits for an element to show on the page (you need an element id).
Then if the page is loaded, it shows page loaded. If the timeout period (in seconds) has passed, it will show the timeout error.
1 | from selenium import webdriver |
If you are new to selenium, then I highly recommend this book.