Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Created August 12, 2022 14:05
Show Gist options
  • Save SarahElson/c102b92b477743e4c59a9f62df486c71 to your computer and use it in GitHub Desktop.
Save SarahElson/c102b92b477743e4c59a9f62df486c71 to your computer and use it in GitHub Desktop.
How To Download File Using Selenium Python?
import unittest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
class Browser(unittest.TestCase):
def setUp(self):
PATH = "/Users/macbookair/Desktop/how_download_files_selenium_python/download"
#Google Chrome
options = Options()
prefs = {"download.default_directory" : PATH}
options.add_experimental_option("prefs",prefs)
self.driver = webdriver.Chrome(options=options)
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