Selenium Python Driver Times Out Before Download File Is Generated

This selenium python script:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
import time

def run():
    print('running')
    driver = webdriver.Chrome()
    driver.set_page_load_timeout(2000)
    driver.set_window_size(1024, 600)
    driver.maximize_window()
    try:
        driver.get("https://www.pjdsafetysupplies.com/Admin/Product/List")
        selectElement = Select(driver.find_element(By.ID, "SearchCategoryId"))
        selectElement.select_by_visible_text('Special Offers')
        search = driver.find_element(By.ID, 'search-products')
        search.click()
        driver.find_element(By.XPATH,".//button[@data-toggle="dropdown"]").click()
        driver.find_element(By.XPATH,".//button[@name="exportexcel-all"]").click()
    except Exception as e:
        print("Page Load Fail:"+str(e))
    finally:
        driver.quit()


run()

should export a csv from a website but the file the website generates is quite large and the script keeps timing out with this error message before the file creation is finished:

HTTPConnectionPool(host=”localhost”, port=54896): Read timed out. (read timeout=120)

I’ve tried setting load_timeout to 2000 but the error message states read timeout is at 120. I’ve also tried setting Timeouts.implicit_wait and Timeouts.script but I get the same error message regardless.

Read more here: Source link