Pythoner Pythoner - 1 year ago 326
Python Question

Save the file to my folder using Selenium?

I am trying to save the downloaded file from the website into my personal desktop folder but the file still gets saved in the Downloads folder. I do not know why Python is doing that. Python does not even display an error. Can someone please provide advice on what is the mistake here.

from selenium import webdriver
from import WebDriverWait
from import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from import By
from import Options

driver = webdriver.Chrome("C:\Python27\Scripts\chromedriver.exe")

number_option = driver.find_element_by_id("cplMain_btnSearch")

delay = 3
WebDriverWait(driver, delay).until(EC.visibility_of_element_located((By.ID,"cplMain_btnExportToExcel")))
print "Page is ready!"
except TimeoutException:
print "Loading took too much time!"

search_button = driver.find_element_by_id("cplMain_btnExportToExcel")

options = webdriver.ChromeOptions()
options.add_argument("download.default_directory=C:/Users/Jake/Desktop/Programming/R Files")
driver = webdriver.Chrome(r"C:\Python27\Scripts\chromedriver.exe", chrome_options = options)


print 'ALL DONE'

When I run the snippet:

Page is ready!

Answer Source

Per the post attached, I do not think it is possible to change the download directory.

Selenium Python Chromedriver Change File Download Path

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download