Add dependencies to your project

There are two ways of adding dependencies as well. You have to select the same method (manual or Maven) that you used to create the project in previous section.

Add manual dependencies

  1. Download the Java bindings as we are using Java to create our scripts.

    http://code.google.com/p/selenium/downloads/list

  2. Create a new folder under the just created project and give it a meaningful name, like libs (as it will contain the project libraries). Right-click project -> new -> Folder

    createNewFolderInProject

  3. Copy selenium-java-[latest-version].zip\selenium-[latest-version]\selenium-java-[latest-version].jar to libs.

  4. Copy also all jars from selenium-java-[latest-version].zip\selenium-[latest-version]\libs to libs directory.

  5. Select all dependencies in libs, right-click on them, and select Build Path -> Add to Build Path. Now, the dependencies are added to Referenced Libraries.

    addtobuildpath

Use maven to manage dependencies

Now we need to add TestNG and Selenium as dependencies to our project. The are two ways of doing it: Right click on the project -> Maven -> Add Dependency. Search for selenium-java and double-click on the one from org.seleniumhq.selenium

OR:

Open the POM.xml file and add the following XML snippet between the <dependencies>...</dependencies> tags:

TestNG:

<dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>6.8.5</version>
</dependency>

Selenium WebDriver:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>2.39.0</version>
</dependency>

Leave a Reply

Your email address will not be published. Required fields are marked *

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