0 votes
1 view
in Devops and Agile by (19.8k points)

I am working on python and selenium. I want to download a file from clicking events using selenium. I wrote the following code.

from selenium import webdriver

from selenium.common.exceptions import NoSuchElementException

from selenium.webdriver.common.keys import Keys

browser = webdriver.Firefox()



I want to download both files from links with the name "Export Data" from the given URL. How can I achieve it as it works with a click event only?

1 Answer

0 votes
by (63.4k points)

You have to find the link using 


 then make a call to click method.

from selenium import webdriver

# To prevent download dialog

profile = webdriver.FirefoxProfile()

profile.set_preference('browser.download.folderList', 2) # custom location

profile.set_preference('browser.download.manager.showWhenStarting', False)

profile.set_preference('browser.download.dir', '/tmp')

profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv')

browser = webdriver.Firefox(profile)




Added profile manipulation code to prevent download dialog.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !