Skip to content
Related Articles

Related Articles

Download File in Selenium Using Python

View Discussion
Improve Article
Save Article
  • Difficulty Level : Hard
  • Last Updated : 04 Jan, 2021
View Discussion
Improve Article
Save Article

Prerequisite: Selenium

Selenium is a powerful tool for controlling web browsers through programs and performing browser automation. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e. Python, Java, C#, etc. We will be working with Python. Selenium Tutorial covers all topics such as– WebDriver, WebElement, Unit Testing with selenium.  In this article, we are going to see to Download the File From Web Page Using Selenium in Python.

For Downloading the File, we will use the click() method. Here our automation we will download a generated text file.

Follow these steps –

  • Enter data
  • Click on generate, it will generate a text file
  • Click on download, it will download the text file

Here we will use id for entering and generating the text file.

When a file is generated it will give a download option, click on it, the download will start.


  • Import module.
  • Make an object for chromedriver.
  • Get URL with get() methods.
  • Create automation text.
  • Create link automation for downloading.

Below is the full implementation:


# Import Module
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
# Open Chrome
driver = webdriver.Chrome(
# Open URL
# Enter text
driver.find_element_by_id('textbox').send_keys("Hello world")
# Generate Text File
# Click on Download Button


Similarly, we can download a PDF file or any other document. 

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!