Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Last active August 12, 2022 14:38
Show Gist options
  • Save SarahElson/8639a91a83e890d1079974331ba54ceb to your computer and use it in GitHub Desktop.
Save SarahElson/8639a91a83e890d1079974331ba54ceb to your computer and use it in GitHub Desktop.
How To Download File Using Selenium Python?
from selenium.webdriver.common.keys import Keys
from utils.locators import *
import time
# Page objects are written in this module.
class Selenium_Playground_Page():
def __init__(self, driver):
self.locator = SeleniumPlaygroundPageLocators
self.driver = driver
def download(self, text):
self.driver.find_element(*self.locator.file_download).click()
self.driver.find_element(*self.locator.data_field).send_keys(text)
self.driver.find_element(*self.locator.generate_file).click()
self.driver.find_element(*self.locator.download_button).click()
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment