Python Selenium Timeout Exception Catch

Almost of your code is working fine except the Driver.Close(). It should be Driver.close(). The TimeoutException will be thrown when the page is not loaded within specific time. See my code below:

from selenium import webdriver
from selenium.common.exceptions import TimeoutException

Driver = webdriver.Firefox()
try:
    Driver.set_page_load_timeout(1)
    Driver.get("http://www.engadget.com")
except TimeoutException as ex:
    isrunning = 0
    print("Exception has been thrown. " + str(ex))
    Driver.close()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)