Installing Maven in local system

Installing Maven in local system.

In this article we will install Maven, will create dependency and run a simple Selenium test case using  TestNG.

  1. Click here to download Maven jar files from Apache official website.Installing Maven in local system.

2.Unzip the downloaded file and place it in separate folder.

 

Installing Maven in local system.

 

3.Folder Structure

Installing Maven in local system.

 

4. Set Environment variable & path variable.

5.Check Maven version using cmd:- mvn -v

Installing Maven in local system.

6. Now lets create a simple project in eclipse as shown below:

7. Project will be created with folder structure as shown below:

8. Replace Pom.xml content with below provided details:

<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>automation.maven</groupId>
<artifactId>automation.maven.selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mavenFisrtP</name>

<packaging>jar</packaging>

<properties>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>

</properties>

<dependencies>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
</dependency>
<!– Adding Selenium dependency –>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerVersion>1.8</compilerVersion>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>

<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>

</configuration>
</plugin>

</plugins>

</build>

</project>

9. Create a simple Selenium test case to open a link in firefox:

Sample code:

 

10. Use mvn clean command to clear all the previous setting.

Installing Maven in local system.

11. Use mvn install command to install missing files as shown in below screenshot:

Installing Maven in local system.

12. Use mvn test command to run the test cases created under maven project: