The Wayback Machine - https://web.archive.org/web/20240627164435/https://www.geeksforgeeks.org/how-to-install-selenium-in-python/
Open In App

How to Install Selenium in Python?

Last Updated : 28 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Selenium Scripts are built to do some tedious tasks which can be automated using headless web browsers.
For example, Searching for some Questions on Different Search engines and storing results in a file by visiting each link. This task can take a long for a normal human being but with the help of selenium scripts one can easily do it
Now, Some of You may be wondering what is headless web browsers. It’s nothing but a browser that can be controlled using these selenium scripts for automation(web tasks). Selenium Scripts can be programmed using various languages such as JavaScript, Java, Python, etc.
How to Use selenium with Python and Linux Environment.
Python should already be installed. It can be 2.* or 3.* version. 
Steps: 
 

  1. Installing Selenium 
     
  2. Installing Webdrivers (headless) 
     
  3. Creating Simple Code 
     

 

Installing Selenium

Whatever Operating System You are Using Python command is Same for Installing Selenium Library.
First Method
Open Terminal/Cmd and Write Command as written Below
 

python -m pip install selenium

Second Method
Alternatively, you can download the source distribution here, unarchive it, and run the command below: 
 

python setup.py install

 

Installing Webdrivers

One Can Install Firefox, Chromium, PhantomJs(Deprecated Now), etc. 
 

  • for using Firefox you may need to install GeckoDriver 
     
  • for using Chrome you may need to install Chromium 
     

In this article, Firefox is used so One can Follow the Below Steps to Install:-
Steps for Linux:-
1. Go to the geckodriver releases page. Find the latest version of the driver for your platform and download it. 
For example: 
 

wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz

2. Extract the file with: 
 

tar -xvzf geckodriver*

3. Make it executable: 
 

chmod +x geckodriver

4. Move Files to usr/local/bin 
 

sudo mv geckodriver /usr/local/bin/

Steps for Windows:-
1. Same as Step 1 in Linux Download the GeckoDriver
2. Extract it using WinRar or any application you may have.
3. Add it to Path using Command Prompt
 

setx path "%path%;GeckoDriver Path"

For Example:- 
 

setx path "%path%;c:/user/eliote/Desktop/geckodriver-v0.26.0-win64/geckodriver.exe"

 

Creating Simple Code

 

Python3




# Python program to demonstrate
# selenium
 
 
from selenium import webdriver
 
 
driver = webdriver.Firefox()
driver.get("https://google.co.in")


Output:
 

python-selenium

 


Similar Reads

How to Install Selenium WebDriver on MacOS?
In this article, we will learn how to install Selenium WebDriver in Python on macOS. Selenium WebDriver is a web framework that permits you to execute cross-browser tests. This tool is used for automating web-based application testing to verify that it performs expectedly. Installation Procedure: Follow the below steps to install Selenium WebDriver
2 min read
How to Install Selenium WebDriver on Windows for Java?
Selenium is an open-source tool for automating testing of web applications which is free and it supports various programming languages such as C#, Java, Perl, PHP, Python, and Ruby. Selenium Webdriver is most well known or you can say famed with Java as of now. In this article, we will look into how to install selenium Webdriver on a Windows operat
3 min read
How to Install Selenium on MacOS?
In this article, we will learn how to install Selenium in Python on MacOS. The selenium package is used to automate web browser interaction from Python. Installation:Method 1: Using pip to install Selenium Follow the below steps to install the Selenium on macOS using pip: Step 1: Install the latest Python3 in MacOS Step 2: Check if pip3 and python3
2 min read
How to Install Selenium Tools on Linux?
Selenium is an open-source umbrella project providing a collection of web browser automation technologies and libraries. Without having to learn a test scripting language, Selenium provides a playback tool for building functional tests. In this article, we will be learning how to install and setup Selenium with Chrome Webdriver in Linux. Installing
2 min read
Selenium Python Tricks
Selenium: Selenium Python bindings provide a convenient API to access Selenium Web Driver like Firefox, Chrome, etc. What is webdriver? Selenium WebDriver is an automation testing tool. When I say automation, it means it automates test scripts written in Selenium. Webdriver Install Chrome: https://sites.google.com/a/chromium.org/chromedriver/downlo
3 min read
Selenium Base Mini Project Using Python
Project Description:-Here, we're going to study a simple SMS bomber trick (for amusing and educational purpose). Selenium is a free tool for automated trying out across exceptional browsers. In this tutorial, we will learn how to ship mechanically range of unsolicited mail SMS for given variety of frequency and interval. Requirement: You need to in
2 min read
Get all text of the page using Selenium in Python
As we know Selenium is an automation tool through which we can automate browsers by writing some lines of code. It is compatible with all browsers, Operating systems, and also its program can be written in any programming language such as Python, Java, and many more. Selenium provides a convenient API to access Selenium WebDrivers like Firefox, IE,
3 min read
Python | SMS Bomber using Selenium
Here, we are going to learn a simple SMS bomber trick (for fun and educational purpose). Selenium is a free tool for automated testing across different browsers. In this tutorial, we will learn to send automatically number of spam SMS for given number of frequency and interval.Requirement: You need to install chromedriver and set path. Click here t
2 min read
Close specific Web page using Selenium in Python
Prerequisites: Selenium Basics, Selenium close() and quit() 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. The close() meth
2 min read
Download Instagram Posts Using Python Selenium module
In this article, we will learn how we can download Instagram posts of a profile using Python Selenium module. Requirements:Google Chrome or FirefoxChrome driver(For Google Chrome) or Gecko driver(For Mozilla Firefox)Selenium package: It is a powerful tool for controlling a web browser through the program. It is functional for all browsers, works on
7 min read
three90RightbarBannerImg