Learn Selenium

Thursday, November 26, 2015

Setting up a project in the Eclipse IDE

Create Project

Let's write our first script code to use selenium web driver with java language in the Eclipse IDE. To setup a project in an Eclipse, follow  below steps.
  1. Open downloaded eclipse.zip file and extract it.
  2. Open the extracted folder, and double click on the executable file called eclipse.exe.
  3. Choose File -> New -> Java Project. A New Java Project dialog appears as shown below. Enter Project name and leave remaining as default selection. Click Next > button.
New Java Project dialog
In the next screen, move to 'Libraries' tab, click on 'Add External JARs' button as shown below and select selenium-java-2.x.jar and selenium-java-srcs-2.x.jar files from the extracted folder.

Add External jar files for build path

Add all available library jar files from the extracted selenium-java -> libs folder into java build settings by click 'Add External JARs' button again.

All libs jar files
 Click on the Finish button.

After project creation, your project will be display at the left panel window in the Package Explorer tab.

Create Package

To create a new package under the project, select project from the hierarchy and choose File -> New -> Package. A New Java Package dialog appears as shown below.
New Java Package dialog
Enter the package name in the provided textbox. Name should be given without any spaces in it. Ex: Package name such as 'automationFramework'. Click Finish button.

After package creation, package will be display in the Package Explorer tab as, Projectname -> src -> Packagename as shown below:

Project hierarchy structure

Create Class

From the package explorer project hierarchy, select project or package and right click and choose New -> Class. A New Java class dialog appears. Enter the class name and select main() method then click Finish button. 

New Java Class dialog
The final project hierarchy structure will be look like below:


Now we are ready for writing automation script using Selenium Webdriver.

Happy testing... :)


No comments:

Post a Comment