Created
August 12, 2022 14:11
-
-
Save SarahElson/e4141f7369743ab1473b2a8347151fe7 to your computer and use it in GitHub Desktop.
How To Download File Using Selenium Python?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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