First Selenium program using Maven+Java

This is basic example to use Webdriver, Maven with Java.

We need Tools:

1.Eclipse – IDE to Build our applications

Download and install Eclipse. I choose Eclipse IDE 
you can choose IDE of you choice.

2.Maven – We need maven to get all our dependencies automatically, which also allows users to reuse same jars across multiple projects

Download and install maven.
Eclipse does not have integrated Maven support out of the box. To add the support, I am going to use Maven Integration (m2e).

Steps to create program

Step 1:  First create a new Maven project. 

In Eclipse: File -> New -> Other  -> Maven -> Maven project

  • Click: Next, Next, Next
  • Type in field Group Id: com.demo.yourCompanyName
  • Type in field Artifact Id: yourProjectName
  • Click: Finish

Step 2 Edit pom.xml

Eclipse should detect the pom.xml changes automatically, build the project and download required dependencies.

After the build is finished, there should be selenium*.jar files under Maven Dependencies under the Project Explorer panel.


<project xmlns="" xmlns:xsi=""



Step 3:

Create a new test class
Right-click over package com.yourcompany.yourclientprojectname 

under src/test/java and select New -> Class

Type in ClassName: OpenFirefox

Java Code:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class OpenFirefox {

public static void main(String[] args)



System.setProperty("webdriver.gecko.driver", "Path to gekco driver\geckodriver.exe");

WebDriver driver = new FirefoxDriver();



Step 4 :

Right click on class RunAs –>java application.

Your firefox browser will open with given URL “

140 total views, no views today