How to download selenium and install Selenium Webdriver with Eclipse and Java Step By Step

Download selenium webdriver and install selenium webdriver is easy. You need to download selenium jar files. Then configure downloaded selenium jar files in eclipse. Actually there is nothing to install except JDK. Let me describe you step by step process of download, installation and configuration of web driver software and other required components. You can view my post about "What is selenium webdriver" if you wants to know difference between WebDriver and selenium RC software tool.


(Note : I am suggesting you to take a tour of Basic selenium commands tutorials with examples before going ahead for webdriver. It will improve your basic knowledge and helps you to create webdriver scripts very easily. )

Steps To Setup and configure Selenium Webdriver With Eclipse and Java

(Note : You can View More Articles On WebDriver to learn it step by step)
Step 1 : Download and install Java in your system
First of all you need to install JDK (Java development kit) software in your system. So your next question will be "how can i download java" VIEW THIS ARTICLE to know how to download and install Java(JDK) software.

Step 2 : Download and install Eclipse
Download Eclipse for Java Developers and extract save it in any drive. It is totally free. You can run 'eclipse.exe' directly so you do not need to install Eclipse in your system.


Step 3 : Download WebDriver Jar Files.
Selenium webdriver supports many languages and each language has its own client driver. Here we are configuring selenium 2 software with java so we need 'webdriver Java client driver'. Click here to go on WebDriver Java client driver download page for webdriver download file. On that page click on 'Download' link of java client driver as shown in bellow image.


(language-specific client driver's version is changing time to time so it may be different version when you will visit download page. )

Downloaded 'webDriver Java client driver' will be in zip format. Extract and save it in your system at path D:\selenium-2.33.0. There will be 'libs' folder, 2 jar files and change log in unzipped folder as shown in bellow figure. We will use all these files for configuring webdriver in eclipse.


Step 4 : Start Eclipse and configure it with selenium 2 (webdriver)

  • Select WorkSpace on eclipse start up
Double click on 'eclipse.exe' to start eclipse software application. First time when you start eclipse software application, it will ask you to select your workspace where your work will be stored as shown in bellow image. Create new folder in D: drive with name 'Webdriverwork' and select it as your workspace. You can change it later on from 'Switch Workspace' under 'file' menu of eclipse.


After selecting workspace folder, Eclipse will be open.
  • Create new project
Create new java project from File > New > Project > Java Project and give your project name 'testproject' as shown in bellow given figures. Click on finish button.




Now your new created project 'testproject' will display in eclipse project explorer as bellow.


  • Create new package
Right click on project name 'testproject' and select New > Package. Give your package name = 'mytestpack' and click on finish button. It will add new package with name 'mytestpack' under project name 'testproject'.


  • Create New Class
Right click on package 'mytestpack' and select New > Class and set class name = 'mytestclass' and click on Finish button. It will add new class 'mytestclass' under package 'mytestpack'.



Now your Eclipse window will looks like bellow.


  • Add external jar file to java build path
Now you need to add selenium webdriver's jar files in to java build path.
  • Right click on project 'testproject' > Select Properties > Select Java build path > Navigate to Libraries tab
  • Click on add external JARs button > select both .jar files from D:\selenium-2.33.0.
  • Click on add external JARs button > select all .jar files from D:\selenium-2.33.0\libs
Now your testproject's properties dialogue will looks like bellow.


That's all about configuration of WebDriver software with eclipse. Now you are ready to write your test in eclipse and run it in WebDriver.

You can Read My Post about how to write and run your first test in WebDriver.


download selenium webdriver, install webdriver, download webdriver selenium, selenium testing, selenium testing tool, how to download selenium webdriver, what is selenium webdriver, webdriver download, selenium webdriver download, selenium automation, selenium download, selenium install, install selenium webdriver, install selenium webdriver in eclipse, eclipse and selenium, java and selenium, how to install a server, selenium driver, how to setup selenium webdriver, download webdriver selenium, selenium webdriver tutorial java

49 comments:

  1. What is the best version of Firefox to use with webdriver?
    Thanks

    ReplyDelete
    Replies
    1. Always use latest version of FF

      Delete
    2. Big thanks it is very helpful

      Delete
    3. Awesome. Thanks a lot. It saved a lot of time. I almost forgot it..

      Delete
  2. What is the best version of Firefox to work with webdriver?
    Thanks

    ReplyDelete
  3. Thanks...
    Helped a lot ..

    ReplyDelete
  4. Very helpful tutorial! thx a lot!

    ReplyDelete
  5. Very Useful..

    Thank you so much..

    ReplyDelete
  6. Thank you. This helped a lot.

    ReplyDelete
  7. Thank you very much. I am a new bee on Ubuntu and Eclipse and this helped me a lot. Looking forward to you other blogs.

    Regards,
    Samkc

    ReplyDelete
  8. Thanks for this it helped me too a lot .

    ReplyDelete
  9. Thank u so much for information

    ReplyDelete
  10. Hi,

    The article is really awesome. But I was stuck while executing the above program. I have followed all the instructions above but when I try to run the program I get the following error in the program console:

    Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
    Command duration or timeout: 32 milliseconds
    Build info: version: '2.39.0', revision: 'ff23eac', time: '2013-12-16 16:12:12'
    System info: host: 'MANU-PC', ip: '192.168.2.6', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_51'
    Session ID: 2f7a49a4-7ca3-4887-89a3-a93106d1c587
    Driver info: org.openqa.selenium.firefox.FirefoxDriver
    Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, browserConnectionEnabled=true, webStorageEnabled=true, nativeEvents=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=26.0}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)
    at practiceSelenium.googleSuggest.main(googleSuggest.java:12)
    Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: f.QueryInterface is not a function

    The webdriver window is opening but nothing is happening after that.

    Please please please help.

    Regards,
    Sreejani

    ReplyDelete
    Replies
    1. It you have used URL like www.yahoo.com then replace it with http://www.yahoo.com and try again

      Delete
  11. Hi,

    Thanks for sharing the information. I tried the above steps.
    I tried to open firefox browser with the url(http://google.com).
    I am using Mac and Firefox version is 27.0.1 with the jar files selenium-java-2.40.0-srcs.jar, selenium-java-2.40.0.jar and other related jar files. I am getting the below error.
    Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: MAC
    Build info: version: '2.40.0', revision: 'fbe29a9', time: '2014-02-19 20:55:11'
    System info: host: 'SR6-Test-Mac-Air.local', ip: '10.4.2.23', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.7.0_21'
    Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.internal.Executable.(Executable.java:72)
    at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:59)
    at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:55)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:96)
    at Package2.Search.main(Search.java:9)
    Can you tell me what I am doing wrong.

    Thanks in advance.

    ReplyDelete
    Replies
    1. Install your firefox in default folder, the issue will be resolved. Like in windows the default folder is C:\Program Files (x86)\Mozilla Firefox

      Delete
  12. Error looks like it is not able to find firefox.exe path. Please add firefox path as bellow.
    For Mac -> export PATH=/my/firefox/path/bin:$PATH in your profile file.
    For windows -> Insert bellow given line before WebDriver driver = new FirefoxDriver();
    System.setProperty("webdriver.firefox.bin","C:\\Program Files\\Mozilla Firefox\\Firefox.exe");

    ReplyDelete
    Replies
    1. Even after doing this am getting the same error

      Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: MAC
      Build info: version: '2.40.0', revision: 'fbe29a9', time: '2014-02-19 20:55:11'
      System info: host: 'SR6-Test-Mac-Air.local', ip: '10.4.2.23', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.5', java.version: '1.7.0_21'
      Driver info: driver.version: FirefoxDriver
      at org.openqa.selenium.firefox.internal.Executable.(Executable.java:72)
      at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:59)
      at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:55)
      at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:96)


      Can you pls guide me to resolve this issue

      Delete
    2. Try installing firefox in default directory C:\Program Files (x86)\Mozilla Firefox. I had the same issue, I tried this and it resolved it.

      Delete
  13. pls send the simple example coding

    ReplyDelete
  14. Thanks for this....It really hepls.

    ReplyDelete
  15. Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function
    at ican.ican.main(ican.java:9)
    Caused by: java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 1 more
    getting Error i m just following the same instruction but still getting error please help me as soon as possible.. also my code is same as written in image

    ReplyDelete
  16. Thanks. Very useful.

    ReplyDelete
  17. Exception in thread "main" org.openqa.selenium.WebDriverException: Unable to bind to locking port 7054 within 45000 ms
    Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:09:00'
    System info: os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_05'
    Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.internal.SocketLock.lock(SocketLock.java:95)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:69)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:200)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:94)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:147)
    at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:85)
    at pac1.sample.main(sample.java:15)

    am getting above error....plz help me out

    ReplyDelete
  18. Need to look In to It. Please visit http://software-testing-tutorials-automation.blogspot.com/p/request-free.html page and fill required detail so that I can look In to It directly using screen sharing.

    ReplyDelete
  19. Hi there!

    Your article is exactly to the point and as all other folks are saying, is awesome.

    Thanks much ! God Bless!!

    ReplyDelete
  20. Hi..

    Really helpful!! Thanks.

    ReplyDelete
  21. Ur article is really helpful. Thanks for sharing it. God bless.

    ReplyDelete
  22. nice and helpful article keep writing

    ReplyDelete
  23. nice and helpful article keep writing

    ReplyDelete
  24. It is clear and upto date. Thx so much

    ReplyDelete
  25. Could any oen help I am getting error when used sendKeys

    "The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
    The method sendKeys(CharSequence...) from the type WebElement refers to the missing type CharSequence"


    ReplyDelete
  26. I have installed all things.....all are working properly....

    I would like to say thank you so much that you have help us......


    Keep it up.....

    ReplyDelete
  27. This is the coolest blog I've ever found. :D
    Thank you so much for sharing.
    Keep up the good work

    ReplyDelete
  28. Now the Selenium 47 version is not supported to the selenium server standalone version 2.53. When I run my test cases by using those, there is an error message that says unable to connect to Firefox. What can I do to solve this issue.

    ReplyDelete
  29. thank you so much :-) its very helpful

    ReplyDelete
  30. Hi,
    Very good article.
    I followed the steps mentioned but i am stuck at a place.
    I have downloaded the zip file for webDriver Java client driver, but when i extract it see one lib folder, License file, Notice file, and just one client-combined-3.1.0-nodeps executable jar file.
    But here in your blog i can see that their are 2 jar files.
    Please help i am stuck

    ReplyDelete
  31. Hi,
    Great Article,
    I followed the steps mentioned to create the setup but i am stuck at one place.
    I have downloaded the webdriver Java client driver zip file, which contains a lib folder, a license file, a notice file and just one jar file: client-combined-3.1.0-nodeps.jar. whereas i can see that there are 2 jar files shown in the steps mentioned in the article. Kindly help.

    ReplyDelete
  32. I've created a powershell module for automatic download of webdrivers. Manual and automatic installation is described here https://github.com/cezarypiatek/Tellurium/wiki/Driver-installation I hope this will be helpful.

    ReplyDelete