Thursday, 27 December 2012

Maven | Selenium Test Execution

Text in ORANGE has to be edited by users or mentioned important through-out this BLOG

Maven is the Central Repository [like a server], where it can store the jar files. Here, we use Maven as a test execution framework.

Set Maven Environment

1| Download Maven
2| Unzip the folder under C:\Program Files\
3| Create a new System Variable under 'Environment Variables'.
Variable: M2_HOME
Value: C:\Program Files\apache-maven-3.0.4

4| Add Maven path under the variable name, 'Path'
Variable value: %M2_HOME%\bin

5| Make sure that maven is configured properly.
6| Open cmd prompt.
7|Type 'mvn -version'

Configure Maven on Eclipse

1| Install Maven plugin in Eclipse IDE using "Eclipse Marketplace.."
2| Create a new 'Maven project' in Eclipse IDE.
Right click on Package Explorer > New > Other
3| Type 'maven' and Click Next.

4| Select the Project location and Click Next.
5| Select an Archetype as shown below and Click Next.

6| Enter the 'Group Id' and 'Artifact Id' and Click Finish.

7| Now, you will see a POM file created below target folder.

Modify POM.xml

1| Create a new class file under src/test/java; Here it is ''
2| Open the POM xml file.
3| Add the following dependencies for a simple test execution.
JUnit, TestNG, selenium-server, selenium-java

This is how the POM looks like,

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








4| The build libraries mentioned under dependencies will automatically added into the project soon-after saving the POM.xml

Maven Test Execution

There are couple of ways to execute Maven Test.

1| In eclipse, right click on the POM.xml > Run As > Maven install

2| In-order to clean existing test results, it is important to 'Maven clean' before executing a new test.
right click on the POM.xml > Run As > Maven clean

1| Open cmd prompt.
2| Move into the project folder.
3| Type 'mvn clean'
4| Type 'mvn install' for test execution

Note| If you've trouble on creating Maven projects using maven-archetype-quickstart [Eclipse],
1| Open cmd prompt
2| Locate the workspace
3| Enter the below to create a maven project
mvn archetype:generate -DgroupId=yourgroupid -DartifactId=yourartifactid -DarchetypeArtifactId=maven-archetype-quickstart


  1. Thanks for the great information in your blog Selenium Training in Chennai

  2. Are you trying to make cash from your websites/blogs via popunder advertisments?
    In case you do, have you considered using Propeller Ads?