Create New Maven Project In Eclipse For Selenium WebDriver + TestNG

Before creating maven project In eclipse IDE for selenium webdriver, You must be aware about maven and It should be Installed properly In your eclipse IDE. Earlier we learnt about what Is maven In THIS POST and how to download and Install maven In THIS POST. So If maven Is Installed In eclipse then you are ready to create new maven project as described In bellow given steps.

Steps to create new maven project

Step 1 : First of all, Open eclipse IDE and go for creating new project from New -> Other as shown In bellow Image.

It will open new project creation window.

Step 2 : Expand Maven folder In new project creation wizard window and select Maven Project and then click on Next button as shown In bellow Image.

It will take you to project name and location selection screen.

Step 3 : On  project name and location selection screen, You can choose work space location for maven project by clicking on browse button. If wants to use default work space location then select that check box and click on Next button as bellow.

It will take you to Archetype selection screen.

Steps 4 : On Archetype selection screen, Select Maven-archetype-quickstart option as bellow and click on Next button.

Step 5 : On next screen, Enter Group Id = STTA, Artifact Id = MavenProject and Package = STTA.MavenProject as shown In bellow Image. Then click on Finish button.

It will create new maven project In eclipse as bellow.

Now your maven project Is created. You can see there Is pom.cml file under your project as shown above.

Step 6 : Now you need to add selenium webdriver and TestNG dependencies with latest version In pom.xml file. Open pom.xml file and copy-paste bellow given code In It and then save It.

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




Current latest version of selenium webdriver Is 2.44.0. TestNG latest version Is 6.8.8. You can change It If version updated version release In future.

Step 7 : Delete existing file from src/testjava folder package and create new class file under same package with name = as bellow.

Now copy-paste bellow given code In that file and save It.
package STTA.MavenProject;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class WebDriverTest {
 WebDriver driver;

  public void verifySearch() {
   driver = new FirefoxDriver();

Above file will show you errors as we do not have Included selenium and testng jar files In project's build path. Here maven will do It automatically for us.

When you save It, It will start building work space by downloading required jar files from maven central repository and store In local repository based on your selenium webdriver and TestNG versions as bellow. It can take 5 to 20 minutes based on your Internet speed.

Running webdriver project from pom.xml file
When above process get completed, You can run your project from pom.xml file. To run It, Right click on pom.xml file and select Run As -> Maven test as shown In bellow Image.

It will start executing webdriver test file. This Is the way to create and run webdriver test In eclipse using maven and testng.


  1. Aravid,

    MAny many thanks for tutorials

    Please send me ur email address

    need to ask some suggesstions

    1. you can contact me on

  2. Thanks for sharing this information.

  3. [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Project 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Project ---
    [INFO] Using 'UTF-8' encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory C:\Users\jaggnath\workspace\Project\src\main\resources
    [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Project ---
    [INFO] Changes detected - recompiling the module!
    [INFO] Compiling 1 source file to C:\Users\jaggnath\workspace\Project\target\classes
    [INFO] -------------------------------------------------------------
    [INFO] -------------------------------------------------------------
    [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    [INFO] 1 error
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 6.490 s
    [INFO] Finished at: 2016-02-23T22:10:07+05:30
    [INFO] Final Memory: 11M/114M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Project: Compilation failure
    [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    [ERROR] -> [Help 1]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1]

    When I am trying to run this code through maven then I am getting this error

    1. Google it man , u will find on stackoverflow

    2. Google it man , Stackoverflow u will find everything

  4. hi
    your posts are very informative..thank you so much for posting...i am new to maven plugin,struggling with one error. unable to create Maven project in eclipse luno getting below error

    Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
    Creating maven-archetype-webapp' has encountered a problem. Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webap p:RELEASE from any of the configured repositories.

    Can you please help me to get out from this

  5. aravind
    tnx a lot
    but i have few doubts to ask could u provide ur mail id??

  6. Thanks a lot Arvind for tutorial,

    Here, I am struggling with error displaying in code, its not disappear. it seem that not getting dependency we added. i added dependency of Selenium,TestNG, Junit as you describes. here is my dependency file. please help








  7. Line below is picked up from the article:-

    "You can see there Is pom.cml file under your project as shown above"
    Rather than pom.cml it should be pom.xml.