0

I like to save the download file to the specific location on my drive e.g D:\ but after running my Python with Selenium code, it returns "Failed - Download error" and more information from Chrome to fix the error are :

  1. Internet connection

  2. Download later

  3. contact web site owner

Following are the codes that I have:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

options = Options()
options.add_experimental_option("prefs", {"download.default_directory":r"D:/"})                                      
s = Service('chromedriver.exe')
driver = webdriver.Chrome(service=s, options=options)
driver.get("http://www.aastocks.com/tc/stocks/market/high-low-stocks.aspx?catg=1&period=3&t=1")
                                 
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CLASS_NAME, "ts2_icon_excel"))).click()

It returns the Failed - Download error.

Any suggestion ?

Ed T
  • 15
  • 3
  • Thanks. I have sorted out the solution from the conversations. – Ed T Feb 10 '23 at 11:41
  • changed the line of code from "options.add_experimental_option("prefs", {"download.default_directory":r"D:/"})" to options.add_argument("download.default_directory=D:/") – Ed T Feb 10 '23 at 11:45

0 Answers0