How to Download, Install and Configure Selenium WebDriver in Eclipse?
March 11, 2020
How to Download, Install and Configure Selenium WebDriver in Eclipse?
Welcome to this Post – ” How to Download, Install and Configure Selenium WebDriver in Eclipse?”.
This post discusses about the ” How to Download, Install and Configure Selenium WebDriver in Eclipse?”. We will focus on which selenium version is needed before we can start working with Selenium WebDriver on Eclipse and how to configure the selenium in the project before start working on the project.
So, go ahead and enjoy reading…
In this Tutorial, you will learn
- Which version of Selenium to download?
- How to install Selenium?
- How to Setup project in Eclipse?
- How to configure Selenium in Eclipse?
Which version of Selenium to download?
The Selenium Server is required when you would like to run Remote Selenium WebDriver. In order to create selenium scripts that interact with the Selenium Server (for example Selenium Remote WebDriver) or you would like to create local Selenium WebDriver scripts, then you need language-specific client drivers.
- Click here to go on WebDriver Java client driver download page for WebDriver download file.
Click on below link to directly go and download the setup:
“Download version 3.141.59”
OR
Second option is look at the section of “Selenium Client and Webdriver Language Bindings”. Here you need to click on download link and you will get pop-up for zip file.
- Save the zip file :
How to install Selenium?
- Extract the files from the zip file, you will see the selenium libs folder and two selenium client version dll files.
- Now move the folder at common location where all your project files are kept.
How to Setup project in Eclipse? Or How to create new project in Eclipse?
- Open Eclipse.
- Click on File-> New Project
- Click on “Java Project”
- Give name to your project say “SeleniumProject”
- Select Java Execution environment – say JAVASE-1.8.
- Click on Finish.
- This will create a new project for you
You can see src folder is empty. Now next step is to create a package and class.
How to Create a New Package in Eclipse?
- Goto your src folder and focus on it.
- Now right-click with mouse and select new from menu.
- Now select Package option from inner menu of New as shown below
- Now give name to your framework, say “automation framework” and click “Finish” and You will see
How to Create a New Class?
- Right-Click on your newly created automationFramework package and select Class
- Give name to the class in the opened pop-up and click Finish.
- Now you will see class created and opened an edit window,
How to Configure Selenium in Project\Eclipse?
OR
How to Add External Jars to Java build path?
Right click on Project “SeleniumProject” > “Select Properties” > “Java build path”.
Then navigate to Libraries tab and click Add External JARs. Navigate to Selenium jar files.
Now select all files under libs folder,
Finally click on “Apply and Close”
Voila!!!! You are done.
That’s all you need to do with configuration of WebDriver in eclipse.
Conclusion
Now you are ready to write your test script in eclipse and run it in WebDriver, like below
package automationFramework; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.WebDriverWait; public class MyClass { public static void main(String[] args) { // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. WebDriver driver = new FirefoxDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Alternatively the same thing can be done like this // driver.navigate().to("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Anything you want!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the page System.out.println("Page title is: " + driver.getTitle()); // Google's search is rendered dynamically with JavaScript. // Wait for the page to load, timeout after 10 seconds (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.getTitle().toLowerCase().startsWith("anything!"); } }); // Should see: "Anything you want! - Google Search" System.out.println("Page title is: " + driver.getTitle()); //Close the browser driver.quit(); } }
If you would like to keep track of further articles on Selenium. I recommend you to SUBSCRIBE by Email and have new Selenium articles sent directly to your inbox.