I am first time learner of Selenium with Python and I am facing the below issue. When I click on a "Download template" link in an application, the OS give the User with the options "Open" or "Save" or "Save as". The script which I provided below is not able to click on "Open" or "Save" or "Save as" to save the file in to the desired default location on the system whoever run the script. Once the file is stored in to a path in local machine then the script need to upload the same downloaded spread sheet using the link "Process New Spreadsheet" in the same application.

Could you please help me to give the complete code to "Save as" the downloaded spread sheet in to a default path in the System and then the code to have the same spread sheet uploaded using the link "Process New Spread sheet" link which is present in the same application.

Appreciate your help.

Below is the code which work till clicking on the "Download Template" link

import time
from selenium import webdriver
from webbrowser import Chrome
import profile
driver = webdriver.Ie('C:/Selenium/IEDriverServer')  # Optional argument, if not specified will search path.

time.sleep(5) # Let the user actually see something!
link = driver.find_element_by_link_text('Download Template')

profile.set_preference('browser.helperApps.neverAsk.saveToDisk', "application/xml,text/xml")

class textpath(object):
driver.find_element_by_name("Internet Explorer").send_keys(textpath)
driver.find_element_by_name('Save as').click()
driver.find_element_by_id('Save as').click()
  • Avoid asking for people to "give the complete code". It is better if you narrow your question down to help resolve a specific issue you are having. Your title implies you can't click the dialog but the details request an upload solution too. Consider separating these out. – ECiurleo Nov 26 '15 at 9:16

The Robot class(java.awt package) should work. Please go through this blog for a better understanding http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/

Not the answer you're looking for? Browse other questions tagged or ask your own question.