In this article I will walk through the steps required to configure Selenium in Eclipse IDE from Scratch. I hope you might have already have installed Java and would have Eclipse IDE as well.
If Java is not installed on your system, then please Download & install the latest Java JDK from here.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Double Click on the JDK installer and follow the on screen instructions to get the JDK installed on your machine.
You can download the latest Eclipse IDE from here (http://www.eclipse.org/downloads/). Here in this tutorial, I have used Eclipse Mars 2 IDE to showcase configuring Selenium in Eclipse IDE.
Now download Selenium from here (http://docs.seleniumhq.org/download/). You will have to download both Selenium Standalone Server & Java Client driver (Selenium Client & WebDriver Language Bindings) as highlighted below.
Selenium Standalone Server is required to run Remote Selenium Web Drivers. In order to create scripts that interact with the Selenium Server (Selenium RC, Selenium Remote WebDriver) or create local Selenium WebDriver scripts, will have to use language-specific client drivers.
Once the required files are downloaded. Extract the downloaded selenium-java-2.53.0 Zip File to a folder as shown below.
Along with the Selenium Standalone Server & Selenium Java Jars the following Jar files which is the available in the extracted libs folder (Shown Below) is also required.
Now that we have installed Java, Downloaded required Selenium Jars & Eclipse IDE, let us look at how to configure Selenium in Eclipse.
Launch Eclipse & Choose a workspace name as shown below.
Once the Eclipse IDE is open, click on File à New Project à Java Project as shown below.
In the Create New Project window, provide a Project Name and click on Next button.
Keep the default settings as is and click on Finish Button.
Now let’s go ahead and create a Libs folder in the created project. Right click on the Package Explorer and choose New à Folder.
Now navigate to the Selenium Demo Project location through Windows File Explorer and copy all the jars mentioned above including Selenium Standalone Server, Selenium-Java and other jars into the libs folder as shown below.
Refresh your workspace in Eclipse IDE. All the jars added should appear in the IDE.
Let us create a Class and write a small piece of Code to Configure & execute a simple Selenium Script as a Java Application.
Right Click on the Project à New à Class
Provide a Package Name & Class Name as shown below and click on Finish Button.
Below is a sample Java Code to invoke Google.com through Firefox Browser.
As you can see in the above code there are some unresolved errors. Let us try to fix them now.
Right click on your Project in the Package Explorer and choose Configure à Configure Build Path option as shown below.
Click on Libraries Tab and select Add Jars.
Navigate to the Project Folder, select all jars from the Libs folder and click on OK button to add the Jars.
Then Click on OK Button. Now click on the errors in the Editor window and import the required packages. Finally your code should be error free as shown below.
Now right Click on the Project / Java File and choose Run As à Java Application to execute the Script.
The Code should execute and you should be able to view the Google Page launched through Firefox Browser.
In this series, Hope I have provided as much as detail possible and you should be able to simply follow the above steps to configure Selenium in Eclipse IDE and run your First Selenium Script.
Keep watching this space for more articles on Selenium. Until then Happy Testing..!!
If Java is not installed on your system, then please Download & install the latest Java JDK from here.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Double Click on the JDK installer and follow the on screen instructions to get the JDK installed on your machine.
You can download the latest Eclipse IDE from here (http://www.eclipse.org/downloads/). Here in this tutorial, I have used Eclipse Mars 2 IDE to showcase configuring Selenium in Eclipse IDE.
Now download Selenium from here (http://docs.seleniumhq.org/download/). You will have to download both Selenium Standalone Server & Java Client driver (Selenium Client & WebDriver Language Bindings) as highlighted below.
Selenium Standalone Server is required to run Remote Selenium Web Drivers. In order to create scripts that interact with the Selenium Server (Selenium RC, Selenium Remote WebDriver) or create local Selenium WebDriver scripts, will have to use language-specific client drivers.
Once the required files are downloaded. Extract the downloaded selenium-java-2.53.0 Zip File to a folder as shown below.
Along with the Selenium Standalone Server & Selenium Java Jars the following Jar files which is the available in the extracted libs folder (Shown Below) is also required.
Now that we have installed Java, Downloaded required Selenium Jars & Eclipse IDE, let us look at how to configure Selenium in Eclipse.
Launch Eclipse & Choose a workspace name as shown below.
Once the Eclipse IDE is open, click on File à New Project à Java Project as shown below.
In the Create New Project window, provide a Project Name and click on Next button.
Keep the default settings as is and click on Finish Button.
Now let’s go ahead and create a Libs folder in the created project. Right click on the Package Explorer and choose New à Folder.
Now navigate to the Selenium Demo Project location through Windows File Explorer and copy all the jars mentioned above including Selenium Standalone Server, Selenium-Java and other jars into the libs folder as shown below.
Refresh your workspace in Eclipse IDE. All the jars added should appear in the IDE.
Let us create a Class and write a small piece of Code to Configure & execute a simple Selenium Script as a Java Application.
Right Click on the Project à New à Class
Provide a Package Name & Class Name as shown below and click on Finish Button.
Below is a sample Java Code to invoke Google.com through Firefox Browser.
As you can see in the above code there are some unresolved errors. Let us try to fix them now.
Right click on your Project in the Package Explorer and choose Configure à Configure Build Path option as shown below.
Click on Libraries Tab and select Add Jars.
Navigate to the Project Folder, select all jars from the Libs folder and click on OK button to add the Jars.
Then Click on OK Button. Now click on the errors in the Editor window and import the required packages. Finally your code should be error free as shown below.
Now right Click on the Project / Java File and choose Run As à Java Application to execute the Script.
The Code should execute and you should be able to view the Google Page launched through Firefox Browser.
In this series, Hope I have provided as much as detail possible and you should be able to simply follow the above steps to configure Selenium in Eclipse IDE and run your First Selenium Script.
Keep watching this space for more articles on Selenium. Until then Happy Testing..!!
How to Configure Selenium in Eclipse IDE
Reviewed by Suntaragali The Smart Techie
on
May 20, 2016
Rating:
No comments: