Introduction
After installing Python, pip, Selenium, and configuring your development environment, the next step is to verify that Selenium has been installed correctly.
Verifying the installation ensures that all required components are working properly before you start writing automation scripts. It helps identify installation or configuration issues early, saving time during development.
In this tutorial, you’ll learn different methods to verify your Selenium installation, including checking the installed package, verifying the Selenium version, and running your first Selenium program.
Why Verify Selenium Installation?
Verifying the installation helps you confirm that:
Python is installed correctly.
pip is working properly.
Selenium has been installed successfully.
Your Python environment can import the Selenium package.
Your development environment is ready for browser automation.
Skipping this step may lead to unexpected errors when running Selenium scripts.
Method 1: Check the Installed Selenium Package
The simplest way to verify the installation is by checking the installed package information.
Windows
pip show selenium
macOS / Linux
pip3 show selenium
Example Output
Name: selenium
Version: 4.x.x
Summary: Python bindings for Selenium
If package information is displayed, Selenium has been installed successfully.
Method 2: Verify Using pip List
You can also check whether Selenium appears in the list of installed Python packages.
Windows
pip list
macOS / Linux
pip3 list
Example Output
Package Version
------------------------
selenium 4.x.x
If Selenium appears in the list, the installation was successful.
Method 3: Verify Using Python
Open the Python interpreter.
Windows
python
macOS / Linux
python3
Now execute the following code:
import selenium
print(selenium.__version__)
Example Output
4.x.x
If the version number is displayed without any errors, Python can successfully import the Selenium package.
Method 4: Run Your First Selenium Program
The best way to verify the installation is by running a simple Selenium script.
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://example.com")
print(driver.title)
driver.quit()
Output
Example Domain
If the browser opens, navigates to the website, prints the page title, and closes successfully, your Selenium installation is working correctly.
Note: If you’re using Selenium 4.6 or later, Selenium Manager automatically downloads and manages the required browser driver in most cases.
Expected Behavior
When the above script runs successfully:
Google Chrome launches.
The browser opens https://example.com.
The page title is printed.
The browser closes automatically.
This confirms that:
Python is working.
Selenium is installed.
Browser automation is functioning correctly.
Common Verification Errors
ModuleNotFoundError
Error
ModuleNotFoundError: No module named 'selenium'
Cause
The Selenium package is not installed in the active Python environment.
Solution
Install Selenium using:
pip install selenium
Browser Does Not Open
Cause
The required browser is not installed or Selenium cannot locate a compatible browser driver.
Solution
Install the browser.
Update Selenium to the latest version.
Ensure Selenium Manager can access the internet during the first execution.
SessionNotCreatedException
Error
SessionNotCreatedException
Cause
The browser version is incompatible with the browser driver.
Solution
Update your browser.
Upgrade Selenium to the latest version.
pip install --upgrade selenium
ImportError
Cause
Multiple Python installations or an incorrect virtual environment.
Solution
Verify that Selenium is installed in the same Python environment used to run your scripts.
Best Practices
Verify Selenium immediately after installation.
Use the latest stable version of Selenium.
Prefer Selenium Manager for browser driver management.
Always run a simple test script before starting a new automation project.
Use a virtual environment to manage project dependencies.
Frequently Asked Questions (FAQs)
How do I check if Selenium is installed?
Run:
pip show selenium
or
pip list
How do I check the installed Selenium version?
Run:
import selenium
print(selenium.__version__)
What is the easiest way to verify Selenium?
Run a simple Selenium program that opens a browser, navigates to a website, prints the page title, and closes the browser.
Why does Python say “No module named selenium”?
This usually means Selenium is not installed in the current Python environment or virtual environment.
Do I need browser drivers to verify Selenium?
If you’re using Selenium 4.6 or later, Selenium Manager automatically handles browser drivers for supported browsers in most cases.
Key Takeaways
Always verify Selenium after installation before starting automation development.
Use
pip show seleniumorpip listto confirm the package is installed.Import Selenium in Python to verify that the package is accessible.
Run a simple Selenium script to ensure browser automation works correctly.
Resolve installation issues before creating larger automation projects.
Verifying the installation helps ensure your Selenium environment is fully configured and ready for automation testing.
