fp = webdriver.FirefoxProfile()
fp.set_preference('http.response.timeout', 5)
fp.set_preference('dom.max_script_run_time', 5)
driver = webdriver.Firefox(firefox_profile=fp)
How to set Selenium Python WebDriver default timeout?