Selenium is widely used for automating web browsers. It plays an important role in testing, helping developers ensure that websites and applications work as expected. Knowing the exact Selenium version you’re using is important to leverage the features.
Different versions support specific browsers and programming languages, and updates often include new features and fixes.
This article talks about simple ways to find out which Selenium version is installed on your system.
How to Check Current Selenium Version
Lets explore how to check the Selenium version in different programming languages using two methods for each. Ensuring you’re using the right Selenium version helps maintain compatibility with your tools and browsers.
Below methods will help you to check your current selenium version:
1. Java
Method 1: Checking in Maven
If you’re using Maven, the Selenium version can be found in the pom.xml file under the <dependency> section:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.x.x</version> <!-- Replace with the actual version you have --> </dependency>
Alternatively, run the following Maven command to list dependencies and their versions:
mvn dependency:tree
For Unix-like systems (Linux/Mac), you can filter for selenium by running:
mvn dependency:tree | grep selenium
On Windows, the grep command may not be available. In that case, simply run
mvn dependency:tree
and then manually search the output for selenium to find the version.
Read More: Maven Dependency Management with Selenium
Method 2: Checking in Gradle
In Gradle, the Selenium version is specified in the build.gradle file under dependencies:
dependencies {
implementation 'org.seleniumhq.selenium:selenium-java:4.x.x' // Replace with the actual version you have
}To verify the version in the terminal, use the Gradle dependencies task:
./gradlew dependencies
For Unix-like systems (Linux/Mac), you can filter for selenium by running:
./gradlew dependencies | grep selenium
On Windows, the grep command may not be available. In that case, simply run ./gradlew dependencies and manually search the output for selenium to find the version.
2. Python
Method 1: Using pip (Command Line)
Run the following pip command to check the installed Selenium version:
pip show selenium
The output will display details like the version:
Name: selenium Version: 4.x.x <!-- Replace with the actual version you have --> ...
Method 2: Python Script
You can also check the Selenium version programmatically using the selenium module:
import selenium print(selenium.__version__)
3. JavaScript / Node.js
Method 1: Using npm (Command Line)
Run the following npm command to view the Selenium version in your project:
npm list selenium-webdriver
Make sure to run this command in the root directory of your project, where the node_modules folder is located. This will display the version of selenium-webdriver installed in your project.
The output will include the installed Selenium version:
selenium-webdriver@4.x.x <!-- Replace with the actual version you have -->
Method 2: Checking in package.json
Before checking the package.json file, run the following command to install or update the dependencies and synchronize the node_modules folder with the package.json file:
npm install
After running npm install,Open the package.json file in your project and look for the selenium-webdriver dependency under the dependencies section:
"dependencies": {
"selenium-webdriver": "4.x.x" <!-- Replace with the actual version you have -->
}This will show you the version of selenium-webdriver currently used in your project.
4. Ruby
Method 1: Using gem (Command Line)
Before running the command, ensure that the correct Ruby environment is active. If you’re using a version manager like rvm or rbenv, make sure the appropriate Ruby version is selected.
Run the following gem command to check the Selenium version:
gem list selenium-webdriver
The output will display the version installed:
selenium-webdriver (4.x.x) <!-- Replace with the actual version you have -->
Method 2: Ruby Script
Check the Selenium version programmatically in a Ruby script:
require 'selenium-webdriver' puts Selenium::WebDriver::VERSION
5. C# / .NET
Method 1: Checking in NuGet
Run the following command in the Package Manager Console:
Get-Package -Name Selenium.WebDriver
The output will include the installed version of Selenium:
Id Versions Selenium.WebDriver 4.x.x <!-- Replace with the actual version you have -->
Method 2: Checking in Code
Use the following snippet in your .NET project to programmatically fetch the version:
Console.WriteLine(typeof(OpenQA.Selenium.WebDriver).Assembly.GetName().Version);
6. PHP
Method 1: Using Composer (Command Line)
Run this command to view the installed Selenium package and its version:
composer show facebook/webdriver
The output will include the version:
name : facebook/webdriver versions : 1.x.x <!-- Replace with the actual version you have --> ...
Method 2: PHP Script
Check the Selenium version programmatically in a PHP script:
<?php
$version = shell_exec('composer show facebook/webdriver | grep versions'); echo "Selenium WebDriver version: " . $version;
?>These methods ensure you can quickly identify the Selenium version in various programming environments. Always keep your setup updated for better compatibility and performance. Make sure to replace 4.x.x with the actual version number you’re using, and consider checking the official repository or package manager for the latest version
Difference Between Selenium 3 and Selenium 4
Selenium has evolved significantly between its third and fourth versions. Selenium 3, released in 2016, was widely used for browser automation. However, with the rapid advancement of web technologies, the need for an updated framework became evident. Selenium 4, released in 2021, introduces major improvements in performance, compatibility, and support for modern web browsers, ensuring that Selenium remains relevant in the fast-evolving landscape of web development.
Here is a comparison of the key differences between Selenium 3 and Selenium 4:
| Feature | Selenium 3 | Selenium 4 |
|---|---|---|
| WebDriver Standard | Custom WebDriver implementations | Fully aligned with W3C WebDriver standard |
| Relative Locators | Not available | Introduced features like toLeftOf, below, near, etc. |
| Selenium Grid | Complex setup with limited features | Enhanced Grid with better scalability and support for Docker |
| Browser Support | Good support for major browsers | Improved support for the latest browsers (Chrome, Edge, Firefox) |
| Mobile Support | Limited mobile testing capabilities | Improved mobile testing with Appium integration |
| Session Management | Less efficient session management | More efficient and stable session handling |
| Performance | Generally satisfactory but could be slow at times | Significant performance improvements |
| Deprecated Features | No major deprecations | Deprecation of older APIs like DesiredCapabilities |
| New Features | – | Native support for relative locators, improved Selenium Grid, enhanced documentation, and debugging tools |
| API Improvements | Limited API enhancements | Significant API improvements for better usability and compatibility |
Best Practices for Using Selenium
When using Selenium for browser automation, following best practices can enhance the stability, maintainability, and efficiency of your test scripts.
Here are several important best practices to follow:
- Use Explicit Waits: Avoid relying on fixed sleep statements. Use explicit waits (WebDriverWait) to wait for specific elements to appear or for certain conditions to be met before interacting with the page. This approach helps make your tests more reliable and reduces the risk of flaky tests.
- Avoid Hardcoded Values: Use variables or configuration files to store URLs, credentials, and other values that might change between environments (like staging, production, etc.). This improves test portability and maintainability.
- Use Page Object Model (POM): Organize your test code using the Page Object Model design pattern. This improves the readability and reusability of test scripts, as well as separates the test logic from the page-specific code.
- Run Tests in Parallel: When running large test suites, execute tests in parallel across multiple browsers or machines. This reduces execution time and helps identify issues in different environments faster.
- Keep Tests Independent: Write tests in a way that each test case is independent and can be run in isolation. Minimize dependencies between tests to avoid cascading failures.
- Capture Screenshots on Failure: Automatically capture screenshots when a test fails. This can provide valuable insights into the state of the application at the time of failure and aid in debugging.
- Version Control: Keep your Selenium scripts and configurations in a version control system (example, Git). This allows you to track changes, collaborate with teammates, and roll back to a previous version if necessary.
- Regularly Update Selenium: Ensure you are using the latest stable version of Selenium to take advantage of new features, improvements, and security patches.
Why Use BrowserStack Automate for Selenium Testing on Real Devices?
BrowserStack Automate offers a robust solution for running Selenium tests on real devices, and here’s why you should consider it:
- Access to Real Devices: BrowserStack allows you to run tests on a wide variety of real devices, rather than emulators or simulators, which provides a more accurate representation of how your application behaves on different devices and browsers.
- Cross Browser Testing: With BrowserStack, you can test your Selenium scripts across multiple browsers, operating systems, and devices. This ensures your web application works seamlessly across different environments.
- Scalability: BrowserStack supports parallel testing, allowing you to run your Selenium tests simultaneously across multiple devices and browsers. This significantly reduces test execution time, especially for large test suites.
- Integration with CI/CD: BrowserStack integrates easily with Continuous Integration/Continuous Deployment (CI/CD) pipelines. It supports popular tools like Jenkins, CircleCI, and Travis CI, enabling automated testing as part of your development workflow.
- No Infrastructure Management: By using BrowserStack, you eliminate the need to maintain in-house infrastructure for device testing. This saves both time and resources that would otherwise be spent on setting up and managing testing environments.
- Real-Time Debugging: BrowserStack provides features like video recordings, screenshots, and console logs, which help in real-time debugging of your Selenium tests. These tools provide valuable insights when a test fails, making it easier to identify the root cause of issues.
- Global Coverage: BrowserStack provides access to a diverse range of real devices from different regions and network conditions, which can help ensure your app performs well globally.
Conclusion
Regularly checking your Selenium version is crucial to ensure your test scripts are utilizing the latest features, bug fixes, performance enhancements, and compatibility with new browser versions. Keeping your Selenium version up to date helps maintain test stability and ensures your tests align with the latest trends in browser automation.
Additionally, BrowserStack Automate improves testing by providing access to real devices, offering scalability, and equipping you with powerful debugging tools. These capabilities make BrowserStack an essential platform for thorough Selenium testing, helping deliver high-quality web applications with consistent performance across all platforms.

