Working with a dialog box to download a file from a site in python

I am trying to automate testing a site that has a form for filling out and loading an excel sheet. Data is sent in an HTTP request. Since it has this, I used urllib2 to get the url, but there is an Open / Save dialog box that appears to load the sheet.

So, I started using selenium , which can handle this function, but there is a javascript function and they cannot pass values.

This is the problem faced by the datepicker file used by calendarDateInput.js and its function is used as

 <td align="center"><script>DateInput('startDate', true, 'YYYY-MM-DD')</script> </td>

I need to pass my date through selenium and tried this:

At first I tried using

driver.find_element_by_id("endDate_Year_ID").clear()
driver.find_element_by_id("endDate_Year_ID").send_keys("2013")

, , javascript

browser.execute_script("document.getElementById('endDate_Year_ID').value = '2013'")

urllib2 , javascript python

Linux, send_keys

.

+3
1

, .

Firefox, . , /path/to/downloads Content-Type (/, /-, /csv ..).

fp = webdriver.FirefoxProfile()
fp.set_preference("browser.download.manager.showWhenStarting",False)
fp.set_preference("browser.download.folderList",2)
fp.set_preference("browser.download.dir", '/path/to/downloads/')
fp.set_preference("browser.download.downloadDir", '/path/to/downloads/')
fp.set_preference("browser.download.defaultFolder", '/path/to/downloads/')
fp.set_preference("browser.helperApps.neverAsk.openFile", "CONTENT-TYPE")
fp.set_preference("browser.helperApps.neverAsk.saveToDisk","CONTENT-TYPE")

:

mydriver = webdriver.Firefox(firefox_profile=fp)
+1

All Articles