HomeSeleniumInstalling Maven in local system

    Installing Maven in local system

    Date:

    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:

    Book a 1-on-1
    Call Session

    Want Patrick's full attention? Nothing compares with a live one on one strategy call! You can express all your concerns and get the best and most straight forward learning experience.

    Related articles:

    How To Execute Selenium Test Cases Using Bat File

    how to Run selenium test cases using bat file. Step...

    Selenium Framework For Beginners

    In this framework we will try to cover all...

    Installing the M2Eclipse Plugin

    We will complete this in two part - In...

    Latest courses:

    Strategic Vision: Mastering Long-Term Planning for Business Success

    Introduction: Professional growth is a continuous journey of acquiring new...

    Leadership Excellence: Unlocking Your Leadership Potential for Business Mastery

    Introduction: Professional growth is a continuous journey of acquiring new...

    Marketing Mastery: Strategies for Effective Customer Engagement

    Introduction: Professional growth is a continuous journey of acquiring new...

    Financial Management: Mastering Numbers for Profitability and Sustainable Growth

    Introduction: Professional growth is a continuous journey of acquiring new...

    Innovation and Adaptability: Thriving in a Rapidly Changing Business Landscape

    Introduction: Professional growth is a continuous journey of acquiring new...