Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Created August 12, 2022 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SarahElson/e4141f7369743ab1473b2a8347151fe7 to your computer and use it in GitHub Desktop.
Save SarahElson/e4141f7369743ab1473b2a8347151fe7 to your computer and use it in GitHub Desktop.
How To Download File Using Selenium Python?
import unittest
from selenium import webdriver
class Browser(unittest.TestCase):
def setUp(self):
PATH = "/Users/macbookair/Desktop/how_download_files_selenium_python/download"
#Mozilla Firefox
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", PATH)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-gzip")
self.driver = webdriver.Firefox(firefox_profile=profile)
self.driver.get("https://www.lambdatest.com/selenium-playground/")
def tearDown(self):
self.driver.close()
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment