Reputation: 43
Some websites tend to keep loading even after all the elements in the page are loaded. This is usually not a problem for humans but selenium tends to wait until the page fully finishes loading even when it could already interact with the given element. Is there a way to bypass this or maybe stop loading when a certain element is detected? I couldnt figure it out from other posts. Thanks
Upvotes: 1
Views: 485
Reputation: 146630
You need to use a load strategy. Default is normal
, other options are eager
and none
https://www.selenium.dev/documentation/en/webdriver/page_loading_strategy/
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.page_load_strategy = 'eager'
driver = webdriver.Chrome(options=options)
# Navigate to url
driver.get("http://www.google.com")
driver.quit()
Upvotes: 1