How do I write code in python using selenium driver to click on save file > do this automaticlly for these files and click on okay as shown in the image?
I'm using pyhon 3.8 and the firefox browser
How do I write code in python using selenium driver to click on save file > do this automaticlly for these files and click on okay as shown in the image?
I'm using pyhon 3.8 and the firefox browser
a better approach will be to directly download the file
from selenium import webdriver
# To prevent download dialog from opening
ff_profile = webdriver.FirefoxProfile()
ff_profile.set_preference('browser.download.manager.showWhenStarting', False)
ff_profile.set_preference('browser.helperApps.neverAsk.saveToDisk','application/xls;text/csv')
browser = webdriver.Firefox(profile)
browser.get("<url>")
browser.find_element_by_id('<file_element_id>').click()
above code will download the file to the default location. if you want to download somewhere else add the following lines:
profile.set_preference('browser.download.folderList', 2) # custom downlaod location
profile.set_preference('browser.download.dir', '<your_path>')