Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in DevOps and Agile by (19.7k 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 (62.9k 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('', 2) # custom location

profile.set_preference('', False)

profile.set_preference('', '/tmp')

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

browser = webdriver.Firefox(profile)




Added profile manipulation code to prevent download dialog.

If you are interested to learn Selenium on a much deeper level and want to become a professional in the testing domain, check out Intellipaat’s Selenium training course!

Browse Categories