{"id":105047,"date":"2020-05-29T10:00:46","date_gmt":"2020-05-29T07:00:46","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=105047"},"modified":"2020-05-27T15:37:35","modified_gmt":"2020-05-27T12:37:35","slug":"maven-tutorial-for-selenium-test-automation","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html","title":{"rendered":"Maven Tutorial For Selenium Test Automation"},"content":{"rendered":"<p>While working on a project for test automation, you\u2019d require all the Selenium dependencies associated with it. Usually these dependencies are downloaded and upgraded manually throughout the project lifecycle, but as the project gets bigger, managing dependencies can be quite challenging. This is why you need build automation tools such as Maven to handle them automatically.<\/p>\n<p>Maven can be more specifically defined as a software project management tool which uses the concepts of project object model (POM). It enables the user to create initial folder structure, perform compilation and testing and then package and deploy the final product. It efficiently cuts down several steps followed in the build process and rather makes the build a one step process.<\/p>\n<p>In this Selenium Maven tutorial, I\u2019ll explain what Maven is and why Maven is important as a build automation tool. Further, I\u2019ll show you how to install Maven for your <a href=\"https:\/\/www.lambdatest.com\/selenium-automation\" target=\"_blank\" rel=\"noopener noreferrer\">Selenium test automation<\/a> projects and running your first project in this Selenium Maven tutorial.<\/p>\n<h2 class=\"wp-block-heading\">Why Use Maven?<\/h2>\n<p>Maven plays a crucial role in managing a project lifecycle, which typically includes validation, code generation, compilation, testing, packaging and much more. It is a software build tool that works in phases rather than tasks(as in the case of Ant). It is basically used to manage the life cycle of a project. Maven makes the build management process much easier, as you\u2019ll only need to specify the dependencies in the pom.xml files and Maven will take care of the rest!<\/p>\n<p>Some of the key reasons Maven is used are:<\/p>\n<ul class=\"wp-block-list\">\n<li>It simplifies the build process &amp; provides a uniform system<\/li>\n<li>It handles compilation, distribution, dependency management and other tasks efficiently.<\/li>\n<li>It increases reusability.<\/li>\n<li>It reduces the steps like adding jar files to the project library, building reports, executing Junit test cases, creating jar\/war\/ear files for deployment.<\/li>\n<li>It has a repository that is centralized that manages jar files.<\/li>\n<\/ul>\n<p>Now that we know why to use Maven, let\u2019s explore a bigger question in this Selenium Maven tutorial, What is Maven?<\/p>\n<p><a href=\"https:\/\/www.lambdatest.com\/blog\/why-you-need-build-automation-tools-for-selenium-automation-testing\/\" target=\"_blank\" rel=\"noopener noreferrer\">Why you need Build Automation Tools for Selenium Automation Testing?<\/a><\/p>\n<h2 class=\"wp-block-heading\">So What Is Maven? Let\u2019s Deep Dive<\/h2>\n<p>By now, you already have the idea that <a href=\"https:\/\/maven.apache.org\/\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">Maven<\/a> is a build automation tool that is used to manage the project dependency and the whole project lifecycle. Maven is built by Apache Software Foundation and is used majorly for Java projects. It was initially developed to make the build process of the Jakarta Turbine Project much simpler and is now widely used to make build processes easy and uniform.<\/p>\n<p>Maven can be more specifically defined as a software project management tool that uses the concepts of the project object model (POM). It enables the user to create an initial folder structure, perform compilation and testing and then package and deploy the final product. It efficiently cuts down several steps followed in the build process and rather makes the build a one-step process.<\/p>\n<p>Some key terms you should know for this Selenium Maven tutorial:<\/p>\n<p><strong>Maven Local repository:<\/strong> It is a local repository in the developer\u2019s machine which holds all the project artifacts. On executing a Maven build, all the project dependent jars are downloaded into the local repository.<\/p>\n<p><strong>Maven Central Repository:<\/strong> It is a default repository in every new project which is official to Maven. Whenever any dependency is not present in local repository Maven automatically consults the central repository to download it.<\/p>\n<p><strong>Project Object Model:<\/strong> POM XML contains project information and configuration details used by Maven build. It is located in the root directory of each project. A sample POM looks like below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-1024x545.png\" alt=\"\" class=\"wp-image-105070\" width=\"768\" height=\"409\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-1024x545.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-300x160.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-768x408.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-620x330.png 620w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial.png 1051w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p><strong>Dependency:<\/strong> Any library on which a java project is dependent on, to run or build is called a dependency. Examples: Log4j jars, Apache Poi jars, Selenium Jars, etc. Dependencies are mentioned in pom.xml as below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"294\" height=\"68\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-1.png\" alt=\"\" class=\"wp-image-105071\"\/><\/figure>\n<\/div>\n<p><strong>Surefire PlugIn:<\/strong> To execute the unit tests of an application during the test phase of the build lifecycle one can use the Surefire Plugin. A surefire report is available in two file formats, viz Plain text file(.txt) and XML file(.xml). This plugin is a must to use as it helps Maven identify tests even when using TestNG or Junit frameworks.<\/p>\n<p><a href=\"https:\/\/www.lambdatest.com\/blog\/selenium-java-testing-page-object-model\/\" target=\"_blank\" rel=\"noopener noreferrer\">Selenium Java Testing: Page Object Model<\/a><\/p>\n<h2 class=\"wp-block-heading\">How to Install Maven In Windows?<\/h2>\n<p>Maven can be installed either through Command-Line or with Eclipse IDE. We\u2019ll first go by the steps on how to install it through Eclipse IDE.<\/p>\n<h3 class=\"wp-block-heading\">How To Install Maven in Eclipse IDE?<\/h3>\n<p>Installing Maven in Eclipse is pretty straightforward, here are the steps involved:<\/p>\n<p><strong>Step 1:&nbsp;<\/strong> Click on Help from the top menu in Eclipse and select \u2018Install New Software\u2019.<\/p>\n<p><strong>Step 2:&nbsp;<\/strong> On the newly opened window, click on the Add button.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency.png\" alt=\"\" class=\"wp-image-105073\" width=\"712\" height=\"602\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency.png 949w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency-300x254.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency-768x649.png 768w\" sizes=\"(max-width: 712px) 100vw, 712px\" \/><\/figure>\n<\/div>\n<p><strong>Step 3:&nbsp;<\/strong> In the name text box type \u201cMaven\u201d, and in the location text box type \u201chttp:\/\/download.eclipse.org\/technology\/m2e\/releases\/\u201d. This URL is the location from where Maven can be downloaded.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"611\" height=\"211\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/add-repository-maven.png\" alt=\"\" class=\"wp-image-105074\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/add-repository-maven.png 611w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/add-repository-maven-300x104.png 300w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><\/figure>\n<\/div>\n<p><strong>Step 4:&nbsp;<\/strong> A check-box will appear in the pop window, Check the check-box and click on the Next button.<\/p>\n<p><strong>Step 5:&nbsp;<\/strong> Wait for a few minutes for the window to complete its process.<\/p>\n<p><strong>Step 6:&nbsp;<\/strong> Keep the default settings and click on the Next button.<\/p>\n<p><strong>Step 7:&nbsp;<\/strong> Accept the Terms &amp; Conditions and click on Finish.<\/p>\n<p><strong>Step 8:&nbsp;<\/strong> Wait for the installation to finish.<\/p>\n<p><strong>Step 9:&nbsp;<\/strong> Once the installation is finished, it will ask you to restart your eclipse. Click on Yes so as to see the changes being reflected.<\/p>\n<p>Boom! This is it. You\u2019ve now installed Maven successfully to your Eclipse IDE.<\/p>\n<p>Just in case you want to go around the other way of installing through the command line, please follow the below steps.<\/p>\n<h3 class=\"wp-block-heading\">How To Install Maven Through Command Line?<\/h3>\n<p>Here are the steps to install Maven through command line in this Selenium Maven tutorial:<\/p>\n<h2 class=\"wp-block-heading\">Step 1:\u00a0 Download &amp; Install Java<\/h2>\n<p>You need to install Java in your system, if not already done. The latest version of java can be downloaded from this link<\/p>\n<p>To check the java version of your system, please go running and type \u2018cmd\u2019 to launch the command prompt. Type \u2018Java -version\u2019 and press Enter to see which java version is installed.<\/p>\n<h2 class=\"wp-block-heading\">Step 2:\u00a0 Set Up Java Environment Variable<\/h2>\n<p>After installation of Java, set up the Java Environment Variable. Open the system settings to set the Java Environment Variable.<\/p>\n<ol class=\"wp-block-list\">\n<li>Go to This PC and right-click on the empty space anywhere within and select Properties<\/li>\n<li>Click on Advanced System Settings so that a new pop up opens up.<\/li>\n<li>Now, from the pop-up window click on Environment Variables<\/li>\n<li>Click on the New button under System variables.<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"697\" height=\"765\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/elenium-Maven-Tutorial.png\" alt=\"\" class=\"wp-image-105075\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/elenium-Maven-Tutorial.png 697w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/elenium-Maven-Tutorial-273x300.png 273w\" sizes=\"(max-width: 697px) 100vw, 697px\" \/><\/figure>\n<\/div>\n<ol class=\"wp-block-list\">\n<li>Type \u201cJAVA_HOME\u201d in the Variable name box and \u2018C:\\Program Files\\Java\\jdk1.8.0_20\u2019 JDK path in the Variable value box and save the same.<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"756\" height=\"220\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/java-file.png\" alt=\"\" class=\"wp-image-105076\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/java-file.png 756w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/java-file-300x87.png 300w\" sizes=\"(max-width: 756px) 100vw, 756px\" \/><\/figure>\n<\/div>\n<ol class=\"wp-block-list\">\n<li>You can now see the newly created Java variable under \u2018System Variables\u2019<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"680\" height=\"275\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-2.png\" alt=\"\" class=\"wp-image-105077\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-2.png 680w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-2-300x121.png 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">Step 3:\u00a0 Download Maven and Set Up Maven Environment Variable<\/h2>\n<ol class=\"wp-block-list\">\n<li>Maven can be downloaded from below location:<br \/><a href=\"https:\/\/Maven.apache.org\/download.cgi\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">https:\/\/Maven.apache.org\/download.cgi<\/a><\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-file-1024x176.png\" alt=\"\" class=\"wp-image-105078\" width=\"768\" height=\"132\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-file-1024x176.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-file-300x51.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-file-768x132.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-file-1536x263.png 1536w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-file.png 1545w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<ol class=\"wp-block-list\">\n<li>Extract it to some location in your machine as per your convenience. For me it is lying at \u2018C:\/apache-Maven-3.6.1\u2019<\/li>\n<li>You can set up the Maven Environment Variable similar to how we set up the Java Environment Variable in steps above.<\/li>\n<li>Type \u2018Maven_HOME\u2018 in the Variable name box and \u2018C:\\apache-Maven-3.6.1\u2019 in the Variable value box.<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"739\" height=\"210\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-automation.png\" alt=\"\" class=\"wp-image-105079\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-automation.png 739w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-automation-300x85.png 300w\" sizes=\"(max-width: 739px) 100vw, 739px\" \/><\/figure>\n<\/div>\n<ol class=\"wp-block-list\">\n<li>You\u2019ll now be able to see the newly created Maven variable under \u2018System Variables\u2019.<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"694\" height=\"327\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorial.png\" alt=\"\" class=\"wp-image-105080\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorial.png 694w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorial-300x141.png 300w\" sizes=\"(max-width: 694px) 100vw, 694px\" \/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">Step 4:\u00a0Updating the Path Variable<\/h2>\n<p>In order to run Maven from the command line, we have to necessarily update the Path Variable with Maven\u2019s installation \u2018bin\u2019 directory.<\/p>\n<ol class=\"wp-block-list\">\n<li>Open system properties through My Computer.<\/li>\n<li>Navigate to \u2018Advanced System Settings\u2019.<\/li>\n<li>Click on \u2018Environment Variables\u2019.<\/li>\n<li>Click on the Edit button under user variables.<\/li>\n<li>Type \u2018PATH\u2019 in the Variable name box &amp; \u2018C:\\apache-Maven-3.6.1\\bin\u2019 in the Variable value box.<\/li>\n<\/ol>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"708\" height=\"768\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-1.png\" alt=\"\" class=\"wp-image-105081\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-1.png 708w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-1-277x300.png 277w\" sizes=\"(max-width: 708px) 100vw, 708px\" \/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\">Step 5:\u00a0Testing the Maven Installation<\/h2>\n<p>Maven is now successfully installed in your system. Now let\u2019s verify it from the Windows command line. Open command prompt and type mvn -version and hit Enter. Check to see the version of Maven installed in your system being displayed in the results.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Now you\u2019re all set with Maven Installation now and can go ahead with creating projects using Maven.<\/p>\n<h2 class=\"wp-block-heading\">Create your First Maven Project<\/h2>\n<p>Just like the Maven installation we discussed earlier in the Selenium Maven tutorial, you can also create a Maven project either through Eclipse IDE or through Command Line.<\/p>\n<h3 class=\"wp-block-heading\">Creating Maven Project with Eclipse IDE<\/h3>\n<p>Below are the steps to create a Maven Project with Eclipse IDE:<\/p>\n<p><strong>Step 1:&nbsp;<\/strong>Create a new project from the Eclipse IDE.<\/p>\n<p><strong>Step 2:&nbsp;<\/strong>From the new project window expand Maven and select Maven Project and then click on Next.<\/p>\n<p><strong>Step 3:&nbsp;<\/strong>You may create a simple project or just let go of this option. For now, we\u2019ll use a simple project which would create a simple Maven-enabled Java project.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"237\" height=\"219\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-project.png\" alt=\"\" class=\"wp-image-105082\"\/><\/figure>\n<\/div>\n<p><strong>Step 4:&nbsp;<\/strong> Now upon clicking Next you\u2019ll need to type information of the Maven project is created. You may refer below descriptions to fill in the values:<\/p>\n<p>Group Id- corresponds to your organization\u2019s name.<br \/>Artifact Id- refers to the project name.<\/p>\n<p>The version can be chosen flexibly. If your project does not have any parent dependencies, you don\u2019t need to fill in the project dependencies. Just fill in the appropriate information and click on \u2018Finish\u2019.<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"704\" height=\"640\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorial-1.png\" alt=\"\" class=\"wp-image-105083\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorial-1.png 704w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorial-1-300x273.png 300w\" sizes=\"(max-width: 704px) 100vw, 704px\" \/><\/figure>\n<p><strong>Step 5:&nbsp;<\/strong> Your Maven project has now been created!<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"281\" height=\"212\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-maven.png\" alt=\"\" class=\"wp-image-105084\"\/><\/figure>\n<\/div>\n<p><strong>Note:<\/strong> Java code is placed in \/src\/main\/java, resources are kept in \/src\/main\/resources, testing code is placed in \/src\/test\/java and the testing resources are placed in \/src\/test\/resources.<\/p>\n<p><strong>Step 6:&nbsp;<\/strong> You may now open the pom.xml to view the structure set up by Maven. You\u2019ll see all the information that we entered in \u2018step 4\u2019 here. You can use the tabs at the bottom to change the view. The pom.xml tab has the pom XML code for the Maven project.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/getting-started-with-maven.png\" alt=\"\" class=\"wp-image-105085\" width=\"666\" height=\"170\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/getting-started-with-maven.png 888w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/getting-started-with-maven-300x77.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/getting-started-with-maven-768x196.png 768w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"752\" height=\"192\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorials.png\" alt=\"\" class=\"wp-image-105086\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorials.png 752w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorials-300x77.png 300w\" sizes=\"(max-width: 752px) 100vw, 752px\" \/><\/figure>\n<\/div>\n<p>The Maven Project is now ready to be used.<\/p>\n<p>Next, let us see how we can create a Maven project using Command-Line.<\/p>\n<p><strong>Step 1:&nbsp;<\/strong> Open a Command Prompt and navigate to the folder where you want to set up your project. Once navigated, type below command:<\/p>\n<p>mvn archetype:generate -DgroupId=demoProject -DartifactId=DemoMavenProject -DarchetypeArtifactId=Maven-archetype-quickstart -DinteractiveMode=false<\/p>\n<p>Here, DgroupId is the organization name, DartifactId is the project name and DarchetypeArtifactId is the type of Maven project.<\/p>\n<p>On clicking Enter, your Maven project will be created.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-code-1024x515.png\" alt=\"\" class=\"wp-image-105087\" width=\"768\" height=\"386\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-code-1024x515.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-code-300x151.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-code-768x386.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-code.png 1396w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p><strong>Step 2:&nbsp;<\/strong> You can go to the project location to see the newly created Maven project. You can open the pom.xml file, which is in the project folder, by default the POM is generated like this:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"560\" height=\"188\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-2.png\" alt=\"\" class=\"wp-image-105088\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-2.png 560w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-2-300x101.png 300w\" sizes=\"(max-width: 560px) 100vw, 560px\" \/><\/figure>\n<\/div>\n<p><strong>Step 3:&nbsp;<\/strong> You can view the default folder structure of your Maven project.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"164\" height=\"135\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-5.png\" alt=\"\" class=\"wp-image-105089\"\/><\/figure>\n<\/div>\n<p>Now that we know how to create a Maven project, let\u2019s try to integrate Selenium with Maven. But before we do that, we need to understand the various Dependencies that would help with this integration.<\/p>\n<h2 class=\"wp-block-heading\">Selenium Maven Dependency For Your Automation Project<\/h2>\n<p>All the external libraries that are used in a project are called dependencies. Maven has an excellent feature that automatically downloads required libraries from its central repository, which makes it easy as you don\u2019t have to store them locally. Below is an example of writing a Selenium Maven dependency in your pom.xml:<\/p>\n<div>\n<div id=\"highlighter_333586\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java plain\">&lt;dependency&gt;<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">&lt;groupId&gt;org.Seleniumhq.Selenium&lt;\/groupId&gt;<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">&lt;artifactId&gt;Selenium-java&lt;\/artifactId&gt;<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">&lt;version&gt;<\/code><code class=\"java value\">4.0<\/code><code class=\"java plain\">.<\/code><code class=\"java value\">0<\/code><code class=\"java plain\">-alpha-<\/code><code class=\"java value\">1<\/code><code class=\"java plain\">&lt;\/version&gt;<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java spaces\">&nbsp;&nbsp;&nbsp;<\/code><code class=\"java plain\">&lt;\/dependency&gt;<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>On adding the above Selenium Maven dependency, Maven will download the Selenium java library into our local Maven repository.<\/p>\n<p>There is another Selenium Maven dependency that can be added to pom.xml based on the requirement. Few examples that you might have to use in our Selenium project are :<\/p>\n<h3 class=\"wp-block-heading\">TestNG Selenium Maven Dependency:<\/h3>\n<p>This would import the testing framework dependency for Java.<\/p>\n<div>\n<div id=\"highlighter_255042\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java plain\">&lt;dependency&gt;<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"java spaces\">&nbsp;<\/code><code class=\"java plain\">&lt;groupId&gt;org.testng&lt;\/groupId&gt;<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java spaces\">&nbsp;<\/code><code class=\"java plain\">&lt;artifactId&gt;testng&lt;\/artifactId&gt;<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java spaces\">&nbsp;<\/code><code class=\"java plain\">&lt;version&gt;<\/code><code class=\"java value\">6.14<\/code><code class=\"java plain\">.<\/code><code class=\"java value\">3<\/code><code class=\"java plain\">&lt;\/version&gt;<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java spaces\">&nbsp;<\/code><code class=\"java plain\">&lt;scope&gt;test&lt;\/scope&gt;<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"java plain\">&lt;\/dependency&gt;<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><a href=\"https:\/\/www.lambdatest.com\/blog\/a-complete-guide-for-your-first-testng-automation-script\/\" target=\"_blank\" rel=\"noopener noreferrer\">A Complete Guide For Your First TestNG Automation Script<\/a><\/p>\n<h3 class=\"wp-block-heading\">Apache POI Selenium Maven dependency:<\/h3>\n<p>This would download the libraries required to access Microsoft format files.<\/p>\n<pre class=\"brush:xml\">\n&lt;dependency&gt;\n\t&lt;groupId&gt;org.apache.poi&lt;\/groupId&gt;\n\t&lt;artifactId&gt;poi&lt;\/artifactId&gt;\n\t&lt;version&gt;3.17&lt;\/version&gt;\n&lt;\/dependency&gt;\n\n&lt;dependency&gt;\n\t&lt;groupId&gt;org.apache.poi&lt;\/groupId&gt;\n\t&lt;artifactId&gt;poi-ooxml&lt;\/artifactId&gt;\n\t&lt;version&gt;3.17&lt;\/version&gt;\n&lt;\/dependency&gt;\n<\/pre>\n<p>You can add these Selenium Maven dependencies in your pom.xml as shown below:<\/p>\n<pre class=\"brush:xml\">\n&lt;project xmlns=\"http:\/\/Maven.apache.org\/POM\/4.0.0\"\n    xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n    xsi:schemaLocation=\"http:\/\/Maven.apache.org\/POM\/4.0.0 http:\/\/Maven.apache.org\/xsd\/Maven-4.0.0.xsd\"&gt;\n    &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n    &lt;groupId&gt;organisationName&lt;\/groupId&gt;\n    &lt;artifactId&gt;myDemoProject&lt;\/artifactId&gt;\n    &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;\n\n    &lt;dependencies&gt;\n\n   \t &lt;dependency&gt;\n   \t\t &lt;groupId&gt;org.Seleniumhq.Selenium&lt;\/groupId&gt;\n   \t\t &lt;artifactId&gt;Selenium-java&lt;\/artifactId&gt;\n   \t\t &lt;version&gt;4.0.0-alpha-1&lt;\/version&gt;\n   \t &lt;\/dependency&gt;\n\n   \t &lt;dependency&gt;\n   \t\t &lt;groupId&gt;org.testng&lt;\/groupId&gt;\n   \t\t &lt;artifactId&gt;testng&lt;\/artifactId&gt;\n   \t\t &lt;version&gt;6.9.10&lt;\/version&gt;\n   \t\t &lt;scope&gt;test&lt;\/scope&gt;\n   \t &lt;\/dependency&gt;\n\n    &lt;\/dependencies&gt;\n      \n\n&lt;\/project&gt;\n<\/pre>\n<p>In case you want to validate how these Selenium Maven dependency import the required libraries, you\u2019ll have to go back to the demo project and see what libraries are present by default. For doing the same you need to right-click on your project name and Configure the Build Path for you project and check under the Libraries tab of the newly opened window:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-tutorial.png\" alt=\"\" class=\"wp-image-105090\" width=\"655\" height=\"475\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-tutorial.png 873w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-tutorial-300x218.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-java-tutorial-768x557.png 768w\" sizes=\"(max-width: 655px) 100vw, 655px\" \/><\/figure>\n<\/div>\n<p>Here you can see the default libraries present in your project for this Selenium Maven tutorial.<\/p>\n<p>For a much clearer vision, I\u2019ll create a sample class to use Selenium components and some testNG annotations. Please note that I\u2019ll create the sample test class under the src\/test\/java folder of our project structure. You can clearly see below that the error correction can be done after adding the libraries.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency-1-1-1024x461.png\" alt=\"\" class=\"wp-image-105092\" width=\"768\" height=\"346\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency-1-1-1024x461.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency-1-1-300x135.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency-1-1-768x346.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Dependency-1-1.png 1401w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>So, now rather than manually adding libraries by configuring the project build path in this Selenium Maven tutorial, I\u2019ll write the dependencies for the project in pom.xml, and Maven will directly download those from its repository. This saves the trouble of doing it manually and reducing the chance of missing out on adding some of the jars. So, here is how you add the dependencies:<\/p>\n<p>The pom.xml before the Selenium Maven dependency is added:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-6-1024x315.png\" alt=\"\" class=\"wp-image-105093\" width=\"768\" height=\"236\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-6-1024x315.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-6-300x92.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-6-768x237.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-6.png 1175w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>Pom.xml after the Selenium Maven dependency is added:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-3.png\" alt=\"\" class=\"wp-image-105094\" width=\"647\" height=\"418\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-3.png 863w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-3-300x194.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-3-768x496.png 768w\" sizes=\"(max-width: 647px) 100vw, 647px\" \/><\/figure>\n<\/div>\n<p>After you have saved and refreshed your project, check the build path and see the Selenium and testNG libraries being added Selenium Maven dependency.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-MavenDependency-1.png\" alt=\"\" class=\"wp-image-105096\" width=\"657\" height=\"655\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-MavenDependency-1.png 876w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-MavenDependency-1-300x300.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-MavenDependency-1-150x150.png 150w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-MavenDependency-1-768x765.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-MavenDependency-1-70x70.png 70w\" sizes=\"(max-width: 657px) 100vw, 657px\" \/><\/figure>\n<\/div>\n<p>Also, you can now go to your test class and see the different options to correct the error thrown in this Selenium Maven tutorial:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"589\" height=\"408\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/demo-project-maven.png\" alt=\"\" class=\"wp-image-105097\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/demo-project-maven.png 589w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/demo-project-maven-300x208.png 300w\" sizes=\"(max-width: 589px) 100vw, 589px\" \/><\/figure>\n<\/div>\n<p>You can simply Import the WebDriver and you\u2019d be good to go. Similarly for @Test annotation just import the testng.annotations.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"451\" height=\"369\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-7.png\" alt=\"\" class=\"wp-image-105098\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-7.png 451w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-7-300x245.png 300w\" sizes=\"(max-width: 451px) 100vw, 451px\" \/><\/figure>\n<\/div>\n<p>You can add more dependencies like apache POI, extent reporting, commons email, or anything that might be specific to your project in a similar fashion to your pom.xml.<\/p>\n<p>Now that I am done with configuring the project, I\u2019ll run the project to see if the tests work fine.<\/p>\n<h2 class=\"wp-block-heading\">Maven Lifecycle In Selenium<\/h2>\n<p>There is a maven lifecycle in Selenium that every Maven build follows. The different methods are simply goals. Before going ahead I\u2019ll explain what these goals are.<\/p>\n<p>Open a command line in your system and type mvn and then Enter.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-3-1024x415.png\" alt=\"\" class=\"wp-image-105099\" width=\"768\" height=\"311\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-3-1024x415.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-3-300x122.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-3-768x312.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-3.png 1087w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>You can see a Build failure message with error being displayed saying that no goal has been defined in this Selenium Maven tutorial. As you parse through this message you can see the different goals that can be defined for our Maven project. I\u2019ll quickly go through these default goals before going into detail about the goals required for the Selenium project.<\/p>\n<ol class=\"wp-block-list\">\n<li>validate: would check if our project is correct and all the required information available<\/li>\n<li>compile: would compile the project source code<\/li>\n<li>test: would unit test the compiled source code of our project<\/li>\n<li>package: would package the compiled code into the distributable formats, like JAR<\/li>\n<li>integration-test: would deploy the package into an environment where we would run the integration tests<\/li>\n<li>verify: would verify if the package is valid<\/li>\n<li>install: would locally install the package<\/li>\n<li>deploy: would be used in integration or release environment by copying the final project into a remote repository where it can be accessed by other projects or developers<\/li>\n<li>clean: cleans up previous build artifacts<\/li>\n<li>site: creates site documentation for the project<\/li>\n<\/ol>\n<p>Of the above-said default goals, three are crucial for Selenium test automation. There are clean, install, and tests.<\/p>\n<p>You can either use these goals alone or use it as a combination like clean-install for this Selenium Maven tutorial.<\/p>\n<p><strong>Clean-<\/strong> It would clean the target folder, i.e. the folder where the previous build\u2019s libraries, build files(war, tar or jar files), reports, output files, etc are saved. On executing mvn -clean this target folder will be deleted.<\/p>\n<p><strong>Install-<\/strong> It would install all the dependencies, in case of missing jars, and create the deployment file(war\/jar files in case of JAVA) and then it\u2019ll run the test.<\/p>\n<p><strong>Test-<\/strong> It will simply run the test without creating any deployment file.<\/p>\n<p>When using Eclipse IDE, you can directly use any of these three goals by right-clicking on your pom.xml, then Run As and selecting any of the options.<\/p>\n<h3 class=\"wp-block-heading\">Maven Clean<\/h3>\n<p>I\u2019ll start with selecting Maven <strong>clean<\/strong> in this Selenium Maven tutorial, you can see the output below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-1-1024x539.png\" alt=\"\" class=\"wp-image-105101\" width=\"768\" height=\"404\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-1-1024x539.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-1-300x158.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-1-768x405.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-1.png 1403w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>So here the task of clean, which is to delete the target folder has been successfully completed and hence our Build is successful.<\/p>\n<h3 class=\"wp-block-heading\">Maven Install<\/h3>\n<p>Before going to the second task of <strong>install<\/strong>, you need to add a plugin called Maven Compiler plugin.Without it the <a href=\"https:\/\/www.lambdatest.com\/selenium-automation\" target=\"_blank\" rel=\"noopener noreferrer\">Selenium test automation<\/a> build will fail. This plugin is used to identify the specific location of the compiler. You can just add the below plugin in your pom.xml and refresh the project before executing Maven install.<\/p>\n<pre class=\"brush:xml\">\n&lt;build&gt;\n   &lt;plugins&gt;\n      \t&lt;plugin&gt;\n  \t&lt;groupId&gt;org.apache.Maven.plugins&lt;\/groupId&gt;\n  \t&lt;artifactId&gt;Maven-compiler-plugin&lt;\/artifactId&gt;\n  \t&lt;configuration&gt;\n    \t&lt;compilerVersion&gt;1.5&lt;\/compilerVersion&gt;\n    \t&lt;source&gt;1.5&lt;\/source&gt;\n    \t&lt;target&gt;1.5&lt;\/target&gt;\n  \t&lt;\/configuration&gt;\n\t&lt;\/plugin&gt;\n\t&lt;\/plugins&gt;\n  &lt;\/build&gt;\n<\/pre>\n<p>Upon adding this piece, your pom.xml would look like below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"646\" height=\"722\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/SeleniumMaven-Dependency.png\" alt=\"\" class=\"wp-image-105102\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/SeleniumMaven-Dependency.png 646w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/SeleniumMaven-Dependency-268x300.png 268w\" sizes=\"(max-width: 646px) 100vw, 646px\" \/><\/figure>\n<\/div>\n<p>Now, go to Maven Install just like you did for Maven Clean in this Selenium Maven tutorial and observe the console output for the build installation:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-4-1-1024x560.png\" alt=\"\" class=\"wp-image-105104\" width=\"768\" height=\"420\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-4-1-1024x560.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-4-1-300x164.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-4-1-768x420.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-4-1.png 1451w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-5-1-1024x573.png\" alt=\"\" class=\"wp-image-105106\" width=\"768\" height=\"430\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-5-1-1024x573.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-5-1-300x168.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-5-1-768x430.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-5-1.png 1428w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"888\" height=\"217\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-8.png\" alt=\"\" class=\"wp-image-105107\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-8.png 888w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-8-300x73.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-8-768x188.png 768w\" sizes=\"(max-width: 888px) 100vw, 888px\" \/><\/figure>\n<\/div>\n<p>You can see in the console output that the Maven installer executed the tests as well. To see the installed directories in your local system you refresh your project and see the directories generated. In the below snapshot you can see all the files generated(a jar file as well since this is a simple JAVA program) as a result of Maven install. You can share this jar file directly for others to execute.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"320\" height=\"198\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-selenium-tutorial.png\" alt=\"\" class=\"wp-image-105108\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-selenium-tutorial.png 320w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-selenium-tutorial-300x186.png 300w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\">Maven Test<\/h3>\n<p>Similarly, we can do <strong>Maven Test<\/strong> in this Selenium Maven tutorial and see the build results in the console:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tests-1024x711.png\" alt=\"\" class=\"wp-image-105109\" width=\"768\" height=\"533\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tests-1024x711.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tests-300x208.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tests-768x533.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tests.png 1155w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>The above steps show how execution can be done through Eclipse IDE, but in real-time project execution is done mostly through the command line So now we would use these goals from the command line. Before proceeding onto these tasks make sure that your current working directory in cmd points to your local workspace location. If we do not do so our Maven command would not be able to find the desired pom.xml and hence our Selenium test automation build would fail.<\/p>\n<p>Let us first do the Maven Clean using the command prompt in this Selenium Maven tutorial. We simply need to write \u2018mvn clean\u2019:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-test-script.png\" alt=\"\" class=\"wp-image-105110\" width=\"619\" height=\"245\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-test-script.png 825w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-test-script-300x119.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-test-script-768x303.png 768w\" sizes=\"(max-width: 619px) 100vw, 619px\" \/><\/figure>\n<\/div>\n<p>You can see the target folder getting deleted. The next step in this Selenium Maven tutorial is to do Maven install which is done by typing \u2018mvn install\u2019 in the command prompt.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-9-1-1024x385.png\" alt=\"\" class=\"wp-image-105112\" width=\"768\" height=\"289\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-9-1-1024x385.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-9-1-300x113.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-9-1-768x289.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-9-1.png 1523w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-10-1-1024x439.png\" alt=\"\" class=\"wp-image-105114\" width=\"768\" height=\"329\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-10-1-1024x439.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-10-1-300x129.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-10-1-768x330.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-10-1-1536x659.png 1536w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-10-1.png 1538w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-11-1-1024x336.png\" alt=\"\" class=\"wp-image-105116\" width=\"768\" height=\"252\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-11-1-1024x336.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-11-1-300x98.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-11-1-768x252.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-11-1-1536x504.png 1536w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-11-1.png 1600w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>You can see the console output is almost similar to what was there through Eclipse execution. Let us now perform a Maven test by typing \u2018mvn test\u2019 which would result in the test being executed without building jar files.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-6-1-1024x837.png\" alt=\"\" class=\"wp-image-105118\" width=\"768\" height=\"628\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-6-1-1024x837.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-6-1-300x245.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-6-1-768x627.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/selenium-test-automation-6-1.png 1071w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>Now that you know the basic goals for executing our automation test you\u2019re good to go to run your automation scripts through Maven!<\/p>\n<h2 class=\"wp-block-heading\">Maven Surefire Plugin<\/h2>\n<p>By now you have read this term in this Selenium Maven tutorial quite some time in your console output logs, so I\u2019ll shed some light on it. The surefire plugin helps Maven to identify the tests and is used with whichever framework your project is built on. To add Surefire plugin to your pom.xml use below code snippet:<\/p>\n<pre class=\"brush:xml\">\n&lt;properties&gt;\n&lt;suiteXmlFile&gt;src\/main\/resources\/testng.xml&lt;\/suiteXmlFile&gt;\n&lt;\/properties&gt;\n\n\n&lt;build&gt;\n&lt;plugin&gt;\n&lt;groupId&gt;org.apache.Maven.plugins&lt;\/groupId&gt;\n&lt;artifactId&gt;Maven-surefire-plugin&lt;\/artifactId&gt;\n&lt;version&gt;2.17&lt;\/version&gt;\n&lt;configuration&gt;\n&lt;suiteXmlFiles&gt;\n&lt;suiteXmlFile&gt;${suiteXmlFile}&lt;\/suiteXmlFile&gt;\n&lt;\/suiteXmlFiles&gt;\n&lt;\/configuration&gt;\n&lt;\/plugin&gt;\n&lt;\/build&gt;\n<\/pre>\n<p>Your pom.xml should look like below:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorialss-1.png\" alt=\"\" class=\"wp-image-105120\" width=\"721\" height=\"605\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorialss-1.png 961w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorialss-1-300x252.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/maven-tutorialss-1-768x644.png 768w\" sizes=\"(max-width: 721px) 100vw, 721px\" \/><\/figure>\n<\/div>\n<p>Here I\u2019ve put in testng.xml in src\/main\/resources and thereby giving its path in properties.<\/p>\n<p>Now I\u2019ll run Maven test from eclipse in this Selenium Maven tutorial and see the results:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-4-1024x425.png\" alt=\"\" class=\"wp-image-105121\" width=\"768\" height=\"319\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-4-1024x425.png 1024w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-4-300x125.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-4-768x319.png 768w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/Selenium-Maven-Tutorial-4.png 1149w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n<\/div>\n<p>You can now check the reports that have been generated by default and in a similar way by typing \u2018mvn test\u2019 can execute this suite from the command prompt.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"322\" height=\"844\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-12.png\" alt=\"\" class=\"wp-image-105122\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-12.png 322w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/05\/pasted-image-0-12-114x300.png 114w\" sizes=\"(max-width: 322px) 100vw, 322px\" \/><\/figure>\n<\/div>\n<p><a href=\"https:\/\/www.lambdatest.com\/blog\/selenium-testing-with-selenide-using-intellij-maven\/\" target=\"_blank\" rel=\"noopener noreferrer\">Also Read: Selenium Testing With Selenide Using IntelliJ &amp; Maven<\/a><\/p>\n<h2 class=\"wp-block-heading\">All In All<\/h2>\n<p>In this Selenium Maven tutorial, I explored how Maven as a build automation tool can make managing Selenium Maven dependency better for your project. With Maven you wouldn\u2019t have to worry about installing and upgrading your project libraries as they are done automatically with the tool. Now you know how to install Maven in your systems with both Eclipse IDE and with the command line. I also explained how to create a Maven project in eclipse. Also, I went through the Maven lifecycle, the goals used, and then I ran the Maven project.<\/p>\n<p>This pretty much sums up everything you need to know to get started with Maven in this Selenium Maven tutorial. Do reach out to us in case of any questions or doubts. Also, I\u2019d appreciate it if you could help us share this article and retweet it. That\u2019s all for now. <strong>Happy Testing!!!<\/strong>\ud83d\ude0a<\/p>\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/accounts.lambdatest.com\/register\/\"><img decoding=\"async\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/01\/Adword-Cyber2.jpg\" alt=\"\" class=\"wp-image-101468\" width=\"698\" height=\"135\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/01\/Adword-Cyber2.jpg 930w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/01\/Adword-Cyber2-300x58.jpg 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2020\/01\/Adword-Cyber2-768x149.jpg 768w\" sizes=\"(max-width: 698px) 100vw, 698px\" \/><\/a><\/figure>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Rahul Rana, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">JCG program<\/a>. See the original article here: <a href=\"https:\/\/www.lambdatest.com\/blog\/getting-started-with-maven-for-selenium-testing\/\" target=\"_blank\" rel=\"noopener noreferrer\">Maven Tutorial For Selenium Test Automation<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>While working on a project for test automation, you\u2019d require all the Selenium dependencies associated with it. Usually these dependencies are downloaded and upgraded manually throughout the project lifecycle, but as the project gets bigger, managing dependencies can be quite challenging. This is why you need build automation tools such as Maven to handle them &hellip;<\/p>\n","protected":false},"author":115205,"featured_media":231,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[670,287,273],"class_list":["post-105047","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-maven","tag-selenium","tag-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Maven Tutorial For Selenium Test Automation - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Maven Tutorial? Check our article explaining what Maven is and why Maven is important as a build automation tool.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Maven Tutorial For Selenium Test Automation - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Maven Tutorial? Check our article explaining what Maven is and why Maven is important as a build automation tool.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-29T07:00:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Rahul Rana\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rahul Rana\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html\"},\"author\":{\"name\":\"Rahul Rana\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c54b59d2df859bc8ace5ebde6bf970d9\"},\"headline\":\"Maven Tutorial For Selenium Test Automation\",\"datePublished\":\"2020-05-29T07:00:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html\"},\"wordCount\":3470,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"keywords\":[\"Maven\",\"Selenium\",\"Testing\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html\",\"name\":\"Maven Tutorial For Selenium Test Automation - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"datePublished\":\"2020-05-29T07:00:46+00:00\",\"description\":\"Interested to learn about Maven Tutorial? Check our article explaining what Maven is and why Maven is important as a build automation tool.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/selenium-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2020\\\/05\\\/maven-tutorial-for-selenium-test-automation.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Maven Tutorial For Selenium Test Automation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c54b59d2df859bc8ace5ebde6bf970d9\",\"name\":\"Rahul Rana\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1b72d07c2c162b31bde94457ec1e84994cf73f8c5b36488e50525cce92d53b4a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1b72d07c2c162b31bde94457ec1e84994cf73f8c5b36488e50525cce92d53b4a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1b72d07c2c162b31bde94457ec1e84994cf73f8c5b36488e50525cce92d53b4a?s=96&d=mm&r=g\",\"caption\":\"Rahul Rana\"},\"description\":\"Rahul works as a Product Marketer at LambdaTest. With his rich experience in the startup world, he wants to help businesses' reach to new heights. Avid tech blogger he also dabbles in music and loves getting lost in fantasy adventures.\",\"sameAs\":[\"https:\\\/\\\/www.lambdatest.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/rahul-rana\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Maven Tutorial For Selenium Test Automation - Java Code Geeks","description":"Interested to learn about Maven Tutorial? Check our article explaining what Maven is and why Maven is important as a build automation tool.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html","og_locale":"en_US","og_type":"article","og_title":"Maven Tutorial For Selenium Test Automation - Java Code Geeks","og_description":"Interested to learn about Maven Tutorial? Check our article explaining what Maven is and why Maven is important as a build automation tool.","og_url":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2020-05-29T07:00:46+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","type":"image\/jpeg"}],"author":"Rahul Rana","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Rahul Rana","Est. reading time":"19 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html"},"author":{"name":"Rahul Rana","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c54b59d2df859bc8ace5ebde6bf970d9"},"headline":"Maven Tutorial For Selenium Test Automation","datePublished":"2020-05-29T07:00:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html"},"wordCount":3470,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","keywords":["Maven","Selenium","Testing"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html","url":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html","name":"Maven Tutorial For Selenium Test Automation - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","datePublished":"2020-05-29T07:00:46+00:00","description":"Interested to learn about Maven Tutorial? Check our article explaining what Maven is and why Maven is important as a build automation tool.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/selenium-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2020\/05\/maven-tutorial-for-selenium-test-automation.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Maven Tutorial For Selenium Test Automation"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c54b59d2df859bc8ace5ebde6bf970d9","name":"Rahul Rana","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1b72d07c2c162b31bde94457ec1e84994cf73f8c5b36488e50525cce92d53b4a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1b72d07c2c162b31bde94457ec1e84994cf73f8c5b36488e50525cce92d53b4a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b72d07c2c162b31bde94457ec1e84994cf73f8c5b36488e50525cce92d53b4a?s=96&d=mm&r=g","caption":"Rahul Rana"},"description":"Rahul works as a Product Marketer at LambdaTest. With his rich experience in the startup world, he wants to help businesses' reach to new heights. Avid tech blogger he also dabbles in music and loves getting lost in fantasy adventures.","sameAs":["https:\/\/www.lambdatest.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/rahul-rana"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/105047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/115205"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=105047"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/105047\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/231"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=105047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=105047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=105047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}