Introduction
Selenium WebDriver is an essential tool for web automation testing. Whether you are using Windows, macOS, or Linux, setting it up correctly ensures smooth test execution. In this guide, you'll learn how to install Selenium WebDriver step by step on all three operating systems.
Step 1: Install a Programming Language
Selenium supports multiple programming languages like Java, Python, C#, and JavaScript. Choose the one you are comfortable with and install it on your system.
For Java Users
- Download and install JDK (Java Development Kit).
- Set the environment variable:
- Windows: Add the
JAVA_HOME
path in system environment variables. - Mac/Linux: Add
export JAVA_HOME=/path/to/java
in.bashrc
or.zshrc
.
For Python Users
- Download and install Python.
- Verify installation using:
python --version
- Install Selenium WebDriver:
pip install selenium
Step 2: Download the WebDriver for Your Browser
Browser | WebDriver Download Link |
---|---|
Google Chrome | ChromeDriver |
Mozilla Firefox | GeckoDriver |
Microsoft Edge | EdgeDriver |
Safari | Pre-installed on macOS (safaridriver ) |
Step 3: Install Selenium WebDriver in Your Project
For Java (Using Maven)
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.x.x</version> </dependency>
For Python
pip install selenium
Step 4: Verify the Selenium WebDriver Setup
Python Example
from selenium import webdriver driver = webdriver.Chrome() driver.get("https://www.google.com") print(driver.title) driver.quit()
Java Example
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class SeleniumTest { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "path/to/chromedriver"); WebDriver driver = new ChromeDriver(); driver.get("https://www.google.com"); System.out.println(driver.getTitle()); driver.quit(); } }
Conclusion
Now you have successfully set up Selenium WebDriver on Windows, Mac, and Linux! 🚀 Start automating web applications using Selenium and take your testing skills to the next level.
Post a Comment