Home > front end >  How to increase Selenium Connection Timeout
How to increase Selenium Connection Timeout

Time:09-24

Due to slow connection, I am getting an following error. I tried explicit and implicit wait. It is giving me the same error. I went through the documentation. Quite impressed had mentioned this issue before

driver.get(f"https://{username}:{password}@theinternalsite")
driver.find_element_by_tag_name('body').screenshot('test.png')
try:
    WebDriverWait(driver,60).until(EC.title_is("Face"))
except:
    WebDriverWait(driver,60).until(EC.title_is("Face"))

selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_CONNECTION_TIMED_OUT

CodePudding user response:

You can do it like this

 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

P.S. if you are doing this for the loading of a page, you can do the following

driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);

CodePudding user response:

If you think it’s from slow loading, you can use pythons time module. This has worked for me in the past, however it’s not a very dynamic solution.

import time
time.sleep(5)
# sleeps for 5 seconds 

You can add this just before the line of code that is getting stuck.

https://docs.python.org/3/library/time.html

  • Related