Maven is a software project management and comprehension tool, It control and manages the plug-in module with POM (Project Object Model) which is basically an XML file format and it contains all plug-in details of the particular project like MVC.

Creating Maven project in eclipse: Note: Following Tools should be installed on your system:

  • JAVA (JDK)
  • Eclipse

1.) Open eclipse and Create a new project using the following screenshot.


Go to “File -> New -> Others” or else we can use File-> New-> Maven Project (if available)

2.) It will show the Dialog like:


Select “Maven project” ->Click “Next” button,

3.) It will show the next dialogue box to select the Archetype (Archetype is a templating toolkit and It defines the pattern of the project), now we are going to select the basic model, see screenshot below.


Select “maven-archetype-quickstart” -> Click “Next ” button.

4.) Add Group ID and Artifact ID, see sample screen-shot below:


5.) Click Finish to complete the maven creation wizard. And after the wizard is closed, we will be in main Eclipse IDE window.


Sample code creation using TestNG:

1.) In the project explorer area, Right click on the Package folder and select the New->Others.


2.) It will show the below dialog box


Select TestNG -> TestNG Class and Click on “Next” button

3.) Now a new window pop-up, fill in the details of the class name and the methods used.


4.) After creating the TestNG class, it will show the codes with error:


5.) Open the Pom.xml file and delete the entire code inside the file. And now replace it with the code provided below.

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



















































And the above-mentioned code will create the TestNG, Selenium and Maven Jar files inside the project.

6.) Now re-run the entire process of TestNG. And all the error message will be fixed automatically.


7.) Copy and paste the code which you created in Selenium IDE or you can use the following code to execute.

Sample Code:

package com.example.tests;

import java.util.regex.Pattern;

import java.util.concurrent.TimeUnit;

import org.testng.annotations.*;

import static org.testng.Assert.*;

import org.openqa.selenium.*;

import org.openqa.selenium.firefox.FirefoxDriver;



public class Untitled {

private WebDriver driver;

private String baseUrl;

private boolean acceptNextAlert = true;

private StringBuffer verificationErrors = new StringBuffer();


@BeforeClass(alwaysRun = true)

public void setUp() throws Exception {

driver = new FirefoxDriver();

baseUrl = "";

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);




public void testUntitled() throws Exception {

driver.get(baseUrl + "/?gws_rd=ssl");


driver.findElement("lst-ib")).sendKeys("Software testing introduction");


driver.findElement(By.linkText("Introduction to Software Engineering/Testing - Wikibooks, open books ...")).click();




@AfterClass(alwaysRun = true)

public void tearDown() throws Exception {


String verificationErrorString = verificationErrors.toString();

if (!"".equals(verificationErrorString)) {






8.) After paste, just change the Package and Class names.

9.) And Right click on the Package folder and select the Run As->TestNG, then it will execute the code after TestNG and Maven Jar files installation.

10.) Result screen will show like the below-mentioned screenshot.