Friday, 26 January 2018

5. Preparing the POM file for Maven

POM xml

If you open the POM.xml from Eclipse [Note: POM.xml is located at the project level in Eclipse], you will notice the contents shown below. [To see the contents, double click pom.xml in Eclipse and then click the pom.xml tab]

<?xml version="1.0" encoding="UTF-8"?> <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>com.selenium</groupId> <artifactId>hrdemoapp</artifactId> <version>0.0.1-SNAPSHOT</version> </project>

Take the POM.xml file from Chapter 3 and overwrite the contents of the POM file. Now the POM.xml in eclipse should look like the one below

<?xml version="1.0" encoding="UTF-8"?> <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>com.selenium</groupId> <artifactId>hrdemoapp</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <selenium.version>3.5.3</selenium.version> </properties> <dependencies> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>${selenium.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.testng/testng --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.11</version> <scope>compile</scope> </dependency> <!-- https://mvnrepository.com/artifact/log4j/log4j --> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>3.17</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.17</version> </dependency> </dependencies> </project>

Once the file is saved, you will notice that the dependent jars listed above start downloading. Moreover a folder called Maven Dependencies is created in which all dependent jars get downloaded.


Your project has been configured for selenium at the basic level. This book will only cover the Maven project setup.

 The addition of dependencies will be a work in progress. We will add the dependencies as and when required. 


No comments:

Post a Comment