https://www.qatechies.com

How to Download, Install and Configure Selenium WebDriver in Eclipse?

How to Download and Setup Selenium In Eclipse

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

  1. Which version of Selenium to download?
  2. How to install Selenium?
  3. How to Setup project in Eclipse?
  4. 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

Which version of Selenium to download-part1

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.

 

Which version of Selenium to download-part2

 

  • Save the zip file :
SaveZipFile

 


How to install Selenium?

  1. Extract the files from the zip file, you will see the selenium libs folder and two selenium client version dll files.
Extract Files
  1. 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”
How to Setup project in Eclipse
  • Select Java Execution environment – say JAVASE-1.8.
  • Click on Finish.
  • This will create a new project for you

    create a new project

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
New Package in Eclipse
  • Now give name to your framework, say “automation framework” and click “Finish” and You will see
package automation framework
Final Package Creation

 


How to Create a New Class?

  • Right-Click on your newly created automationFramework package and select Class
How to Create a New Class
  • Give name to the class in the opened pop-up and click Finish.
create a class
  • Now you will see class created and opened an edit window,
Final Class Creation

 


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”.

How to Configure Selenium in Project

 

Then navigate to Libraries tab and click Add External JARs. Navigate to Selenium jar files.

Add Selenium Client Version

 

Now select all files under libs folder,

Select Libs Folder Files

 

Finally click on “Apply and Close”

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

write your test script in eclipse
write your test script in eclipse

 

 

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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

advanced-floating-content-close-btn
https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5034726663464946 (adsbygoogle = window.adsbygoogle || []).push({});
advanced-floating-content-close-btn 
*************************** Do you want to learn TOSCA? Do you want to excel in Career? Try my New Courses: 1. Tricentis Tosca and Working with Excel   2. Tricentis Tosca and UI Automation Great News!!   Price has been slashed down for limited period of time.So Hurry!!! Click The Shown Links and Enjoy Learning. ***************************
 
error: Content is protected !!