Selenium Eclipse

Posted on  by admin
By Tim Brown May 20, 2020 java, selenium, eclipse
Selenium Eclipse

This guide assumes that you already have Eclipse and Java installed. You’ll want to download the latest stable Java release from the Selenium website.

Configuring WebDriver
Once downloaded, extract the zipped file to a folder of your choosing. I personally put Eclipse right in my C: directory and put the Selenium files within a folder called “selenium”. The extracted files will be all of the required jar files which enable you to create test scripts in Java.

Next, you’ll want to download a web driver for Selenium. The example is going to use Chrome. Check your Chrome version and make sure to download the appropriate one for your browser from the ChromeDriver website. Once downloaded, extract the zipped file to a folder of your choosing. I personally put the drivers all under my selenium folder within a folder called “drivers”.

TestNG-Eclipse Setup. Step 1 − Launch Eclipse and create a 'New Java Project' as shown below. Step 2 − Enter the project name and click 'Next'. Step 3 − Navigate to 'Libraries' Tab and Add the Selenium Remote Control Server JAR file by clicking on 'Add External JAR's' as shown below. Unfortunately, delving into one of the most popular frameworks — Selenium — can be confusing and convoluted. That is why I wrote this article — to show how, in 2017, you can delve into Selenium.

Configuring Libraries with Eclipse IDEOpen the Eclipse IDE and create a new java based project following File -> New -> Java Project. For now, just call it “seleniumTest”, so that you can follow along.


Select Don’t Create for the module:

Right click on the project folder and select Properties:

Eclipse

Go to “Java Build Path” and select the “Libraries” tab. Next, press the “Add External JARs” button, select all of the selenium libs, and Press the “Open” to add them:

Also, add the selenium jars too:

Press the “Apply and Close” button:

Right click on the project folder, go to New and select to add a new Class:

Name the new Java class “FirstTest” and press the “Finish” button:

If you’ve followed the naming above you should be able to copy and paste the below code into your class replacing the whole thing.

Save the class and then in the menu go to Run -> Run:

Selenium Eclipse

Chrome should open the wiki page for Pizza and verify the title successfully, so you should see a “Test Passed!” in the Console output:

Selenium Eclipse Install

That’s it! You ran your first Java Selenium test within the Eclipse IDE. As always, stay inb8a!