Introduction
This article is a part of a 30 day Python challenge series. You can find the links to all the previous posts of this series here:
- 30 Days of Python 👨💻 - Day One - Introduction
- 30 Days Of Python 👨💻 - Day 2 - Data Types I
- 30 Days of Python 👨💻 - Day 3 - Data Types II
- 30 Days Of Python 👨💻 - Day 4 - Data Types III
- 30 Days Of Python 👨💻 - Day 5 - Conditions And Loops I
- 30 Days Of Python 👨💻 - Day 6 - Loops II And Functions
- 30 Days Of Python 👨💻 - Day 7 - Developer Environment
- 30 Days Of Python 👨💻 - Day 8 - OOP Basics
- 30 Days Of Python 👨💻 - Day 9 - OOP Pillars
- 30 Days Of Python 👨💻 - Day 10 - OOP Missing Pieces
- 30 Days Of Python 👨💻 - Day 11 - Functional Programming
- 30 Days Of Python 👨💻 - Day 12 - Lambda Expression And Comprehensions
- 30 Days Of Python 👨💻 - Day 13 - Decorators
- 30 Days Of Python 👨💻 - Day 14 - Handling Errors
- 30 Days Of Python 👨💻 - Day 15 - Generators
- 30 Days Of Python 👨💻 - Day 16 - Module Basics
- 30 Days Of Python 👨💻 - Day 17 - External Modules
- 30 Days of Python 👨💻 - Day 18 - File I/O
- 30 Days Of Python 👨💻 - Day 19 - Regular Expressions
- 30 Days Of Python 👨💻 - Day 20 - Debugging And Testing
- 30 Days Of Python 👨💻 - Day 21 - Scripting Basics
- 30 Days of Python 👨💻 - Day 22 - Scripting Extras
- 30 Days Of Python 👨💻 - Day 23 - Web Scraping
- 30 Days Of Python 👨💻 - Day 24 - Web Development Basics
- 30 Days Of Python 👨💻 - Day 25 - Web Development Extras
- 30 Days of Python 👨💻 - Day 26 - Machine Learning Basics
- 30 Days Of Python 👨💻 - Day 27 - ML And Data Science
- 30 Days Of Python 👨💻 - Day 28 - ML And Data Science II
Today I explored end-to-end Browser Automation Tests using Python by creating a basic automation testing project.
When it comes to implementing browser automation, Selenium is one of the most popular and widely used libraries. The Selenium Python library makes it very easy to use it with Python and run scripts to perform automated tests on websites.
Automation tests are essential for testing web applications in a real-world scenario, just as how a user would normally use the application. It is also used to perform cross-browser tests to ensure the application works on all target browsers.
I created a basic project to understand and implement the basics of browser automation testing with Selenium.
Creating a project
I created a new directory python-selenium and added a virtual environment to the project.
python -m venv venv
Installing Selenium
The next step is to install the Selenium package which can be installed in the project environment using the command:
pip install selenium
Installing the Drivers
Selenium uses drivers to interface with the browser. So browser-specific drivers need to be installed so that Selenium is able to create the browser instance for running the automation tests.
| Chrome: | https://sites.google.com/a/chromium.org/chromedriver/downloads |
| Edge: | https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ |
| Firefox: | https://github.com/mozilla/geckodriver/releases |
| Safari: | https://webkit.org/blog/6900/webdriver-support-in-safari-10/ |
I downloaded the Firefox driver for this particular project. The driver needs to be the executable path.
(In Windows 10, place the driver file in the path where the Python application is installed, or any other location whose path is there in the environment variables)
Creating a Sample Automation Script
I created a Python script file automation.py in the root project directory.
Here is a simple code for opening a webpage using Selenium:
automation.py
- from selenium import web-driver
- browser = webdriver.Firefox()
- browser.get('https://tabandspace.com')

Join the conversation! Your thoughts help the community grow.