Setting Up Selenium WebDriver Project Using Java

Setting Up Selenium WebDriver Project Using Java

 

Selenium WebDriver

Setting Up the Selenium WebDriver Project Using Java

Let’s learn how to install Selenium WebDriver means to set up a project in development so you can write a program using Selenium. How you do this depends on the programming language and development environment. Therefore, it is very important to learn programming languages such as java and python.

Java with Selenium WebDriver

The easiest way to set up a Selenium 2.0 Java project is to use Maven. Maven will download the java bindings (the Selenium 2.0 java client library) and all its dependencies and will create the project for you, using a maven pom.xml (project configuration) file. Once you’ve done this, you can import the maven project into preferred IDE, IntelliJ IDEA or Eclipse.

First, create a folder to contain Selenium project files. Then, to use Maven, you need a pom.xml file. This can be created with a text editor. We won’t teach the details of pom.xml files or for using Maven since there are already excellent references on this. pom.xml file will look something like this. Create this file in the folder you created for project.

<?xml version=”1.0″ encoding=”UTF-8″?>

<project xmlns=”http://maven.apache.org/POM/4.0.0″

xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>

<modelVersion>4.0.0</modelVersion>

<groupId>MySel20Proj</groupId>

<artifactId>MySel20Proj</artifactId>

<version>1.0</version>

<dependencies>

<dependency>

<groupId>org.seleniumhq.selenium</groupId>

<artifactId>selenium-java</artifactId>

<version>2.45.0</version>

</dependency>

</dependencies>

</project>

Be sure you specify the most current version. At the time of writing, the version listed above was the most current, however there were frequent releases immediately after the release of Selenium 2.0. Check the Maven download page for the current release and edit the above dependency accordingly.

Now, from a command-line, CD into the project directory and run maven as follows.

mvn clean install

This will download Selenium and all its dependencies and will add them to the project. Finally, import the project into a preferred development environment. For those not familiar with this, we’ve provided an appendix which shows this.

 

Selenium professional free practice test

Go back to Tutorial                                                                                Go to Home Page

Share this post
[social_warfare]
Selenium Testing | Selenium WebDriver
Vskills Configuring Selenium WebDriver Using C# & Python

Get industry recognized certification – Contact us

keyboard_arrow_up