When I use selenium, it works well until I minimize/resize the chromedriver.exe window. When I do so, exceptions such as "element not found"
are being raised.
What can I do to avoid this?
Asked
Active
Viewed 154 times
0

ErikDz
- 13
- 4
-
Please produce a minimal example. – Arundeep Chohan Sep 02 '20 at 22:36
1 Answers
0
First, You can try headless:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu') # Last I checked this was necessary.
driver = webdriver.Chrome(CHROMEDRIVER_PATH, chrome_options=options)
Second, You can try wait:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Firefox()
driver.get("http://somedomain/url_that_delays_loading")
try:
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "myDynamicElement"))
)
finally:
driver.quit()

William
- 3,724
- 9
- 43
- 76