Skip to content

Iptv Assist

Learn More from us

Menu
  • HOW TO
  • Firestick
  • Chromecast
  • PC Apps
  • Lg Smart TV
  • IPTV Services
  • Automation Testing
  • Smart TV
  • Software Testing Tools
  • Contact Us
Menu

Use of Maven Build Automation Tool and Maven Project Setup for Selenium – Selenium Tutorial #24

Posted on September 24, 2023

Best Iptv Service Provider 2023 With 40k+ Channels And 100k+ VOD . 24/7 Suppport . Paypal Supported

In our previous Selenium tutorial, we acquired knowledge about a build tool called “Apache Ant”. We also extensively discussed its applicability and importance along with the practical approach.

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

In this Selenium Testing tutorial, we will explore Maven – a build automation tool which is distributed under the Apache Software Foundation. It is primarily utilized for Java projects. It ensures consistency in building projects.

Recommended IPTV Service Providers

  1. IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
  2. IPTVRESALE – Rating 5/5 ( 200+ Reviews )
  3. IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
  4. IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
  5. IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
  6. IPTVTOPS – Rating 5/5 ( 43 Reviews )

 

Maven is also used to manage dependencies. For instance, if you are using version 2.35 of Selenium and need to switch to another version later on, Maven can handle this easily. We will discuss more examples of this later in this chapter. Maven works effectively when dealing with a large number of Jar files with different versions.

Use of Maven Build Automation Tool and Maven Project Setup for Selenium

Key Learning Points:

  • Definition of a build tool
  • Build Life Cycle
  • Maven Setup
  • Installing maven IDE in Eclipse
  • Building the Project
  • Conclusion

Definition of a build tool

A build tool is used to set up everything required to independently run your Java code. This can be applied to your entire Java project. It generates source code, compiles code, and packages code into a JAR file, among other tasks. Maven provides a common platform to perform these activities, making the programmer’s life easier when handling large projects.

Maven provides the pom.xml file, which is the core of any project. It acts as the configuration file where all the necessary information is stored. Many Integrated Development Environments (IDEs) are available to facilitate its usage, such as Eclipse, NetBeans, and IntelliJ.

Maven stores all project JAR files in a repository, which can be a central, local, or remote repository. Maven downloads the necessary dependency JARs from a central repository. Most commonly used libraries are available at http://repo1.maven.org/maven2/.

Downloaded libraries are stored in the local repository called “m2”. Maven uses the libraries available in the “m2” folder, and if any new dependency is added, Maven downloads it from the central repository to the local repository. If libraries are not available in the central repository, Maven looks for them in the remote repository. The user has to configure the remote repository in the pom.xml file to download from it.

Here is an example of configuring a remote repository in the pom.xml file. Provide an ID and URL for the repository where the libraries are stored:

<repositories>
     <repository>
         <id>libraryId</id>
         <url>http://comanyrepositryId</url>
     </repository>
</repositories>

General Phrases used in Maven:

  • groupId: Typically, the groupId refers to a domain ID. Best practice is to use the company name as the groupId, as it helps uniquely identify the project.
  • artifactId: It is basically the name of the JAR file without the version.
  • version: This tag is used to specify the version of the project.
  • Local repository: Maven downloads all the required dependencies and stores them in the local repository called “m2”. More details about this will be shared in the next topic.

Build Life Cycle

The basic Maven phases are used as follows:

  • clean: Deletes all artifacts and targets that have been previously created.
  • compile: Used to compile the source code of the project.
  • test: Tests the compiled code. These tests do not require packaging or deployment.
  • package: Packages the project, converting it into a JAR or WAR file, for example.
  • install: Installs the package into the local repository for use by other projects.

Maven Setup

Step 1: To set up Maven, download the latest version of Maven from the Apache website, depending on your operating system.

Step 2: Unzip the downloaded folder and save it on your local disk.

Step 3: Create an environment variable for MAVEN_HOME. Follow the steps below:

Navigate to System Properties -> Advanced System Settings -> Environment Variable -> System Variable -> New -> Add the path of the Maven folder.

Maven Tutorial 1

Maven Tutorial 2

Step 4: Edit the PATH variable and provide the path to the bin folder.

Maven Tutorial 3

Step 5: Verify the Maven installation by using the command prompt and don’t forget to set up JAVA_HOME.

Use “mvn –version” to verify the Maven version. The output should be similar to the following:

Maven Tutorial 4

Installing Maven IDE in Eclipse

Maven provides an IDE integration for Eclipse. Here, we will use Eclipse Juno for the demonstration.

Navigate to Help -> Eclipse Marketplace -> Search for “maven” -> Install “Maven Integration for Eclipse”

Maven Tutorial 5

After installation, restart Eclipse.

Then, right-click on the pom.xml file and verify that all the required options are available, as shown below. 

Maven Tutorial 6

Creating a Maven project:

Step 1: Navigate to File -> New -> Other -> Maven -> Maven Project -> Click Next

Maven Tutorial 7

Step 2: Check the “Create a simple project” option and click Next

Maven Tutorial 8

Step 3: Provide the Group Id and Artifact Id. You can change the version of the JAR file as per your requirements. Here, I am using the default name. Click Finish.

Maven Tutorial 9

Step 4: After finishing the setup, you will find that the project structure has been created, as shown below. The pom.xml file is created and is used to download all the necessary dependencies.

Maven Tutorial 10
The pom.xml file looks like the following:

<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.softwaretestinghelp.test</groupId>
<artifactId>com.softwaretestinghelp.selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
</project>

Step 5: Add dependencies for Selenium.

All Selenium Maven artifacts are available in the central repository at:

http://repo1.maven.org/maven2/org/seleniumhq/selenium/

Add the following dependencies in the pom.xml file:

 <dependency>
       <groupId>org.seleniumhq.selenium</groupId>
       <artifactId>selenium-java</artifactId>
       <version>2.41.0</version>
 </dependency>

Similarly, the following is the dependency for JUnit:

<dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
</dependency>

If you want to add other third-party JAR files, you can include those dependencies in the pom.xml file as well.

Step 6: The final pom.xml file will look like the following:

<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.softwaretestinghelp.test</groupId> <artifactId>com.softwaretestinghelp.selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
       <groupId>org.seleniumhq.selenium</groupId>
       <artifactId>selenium-java</artifactId>
       <version>2.41.0</version>
   </dependency>
   </dependencies>
</project>

Step 7: Maven will download all the necessary dependency JARs into the local repository called “.m2”.

The “.m2” folder is usually located at Users -> username -> .m2.

All the JAR files will be placed in a repository folder within the “.m2” folder. Maven creates separate folders for different versions and different group IDs.

Maven Tutorial 11

Step 8: If the “.m2” folder does not appear in Maven dependencies, you can manually add the JAR files:

  • Eclipse: Windows -> Preference
  • Navigate to Java -> Build Path -> Classpath Variables

Maven Tutorial 12

  • Click the New button -> Define M2_REPO and provide the path to the “.m2” folder.

Step 9: After a successful setup, you will find a Maven Dependencies folder containing the required dependency JARs for the project.

Maven Tutorial 13

Building the Project

The project can be built using either the IDE or the command prompt.

To build the project using the IDE, right-click on the POM file and select “Run As” -> “Maven Build”.

Maven Tutorial 14

Enter goals such as “clean install” and click “Run”.
The same can be done using the command prompt by navigating to the project folder where the pom.xml file is located, and using the following commands to clean, compile, and install:

For clean: mvn clean
For compile: mvn compile
For Install: mvn install

Upon successful execution, you will see the following information displayed when cleaning a project, along with the message “BUILD SUCCESS”:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building com.softwaretestinghelp.0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
 [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ com.softwaretestinghelp ---[INFO] Deleting C:UsersrshwusWORKSPACEcom.softwaretestinghelptarget
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.702s
[INFO] Finished at: Sat May 24 18:58:22 IST 2014
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------

Conclusion

Maven simplifies the handling of code and the process of building projects. Most projects follow the Maven structure.

Download all the necessary dependencies from the Maven Central Repository. If a dependency is not available in the Maven Central Repository, you need to add the repository path explicitly in the pom.xml file.

While other build tools like Ant are available, it is recommended to use Maven for managing different versions and dependencies. Maven can also manage the dependencies of dependencies, which other tools may not provide. If you have any queries related to Maven, feel free to ask.

Next Tutorial #25: In the upcoming tutorial, we will discuss Hudson, a continuous integration tool. We will explore its importance, role, and benefits in Test Automation Framework. We will cover the installation and working of Hudson from the beginning.

Related

Best Iptv Service Provider 2023 With 40k+ Channels And 150k+ VOD . Hurry Up

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • What Scares Testers Most? – The Tester’s Horror Stories (Halloween Special)
  • What Is Mutation Testing: Tutorial With Examples
  • 9 Ways to Quickly Improve Your Writing Skills as a Software Tester
  • How Do You Decide Which Defects are Acceptable for the Software to Go-live?
  • TestLodge Tutorial – How to Organize Your Software Testing Projects Using TestLodge Test Management Tool

Recent Comments

  1. How to Install and Watch NFL Game Pass on Roku? - Iptv Assist on How to Install and Watch NFL Game Pass on PS5 in 2023?
  2. How to Find Maximum Valid Defects in Any Application? - Iptv Assist on Why Does Software Have Bugs?
  3. How to Get and Watch NFL Game Pass on Samsung smart TV? - Iptv Assist on How to Install and Watch NFL Game Pass on PS5 in 2023?
  4. Chromecast Steam | How to cast Steam Games to TV? [Updated 2023] - Iptv Assist on How to Install & Watch ESPN+ on LG Smart TV? [Updated November 2023]
  5. How to Root Chromecast? [Simple Steps] - Iptv Assist on How to Copy Text from Image on iOS 15?

Archives

  • December 2023
  • November 2023
  • October 2023
  • September 2023

Categories

  • Activate
  • Agile Testing
  • Alternatives
  • Android
  • APK
  • Apple TV
  • Automation Testing
  • Basics of Software Testing
  • Best Apps
  • Breakfast Hours
  • Bug Defect tracking
  • Career in Software Testing
  • Chromebook
  • Chromecast
  • Cross Platform
  • Database Testing
  • Delete Account
  • Discord
  • Error Code
  • Firestick
  • Gaming
  • General
  • Google TV
  • Hisense Smart TV
  • HOW TO
  • Interview Questions
  • iPhone
  • IPTV
  • IPTV Apps
  • Iptv Service SP
  • IPTV Services
  • JVC Smart TV
  • Kodi
  • Lg Smart TV
  • Manual Testing
  • MI TV
  • Mobile Testing
  • Mod APK
  • newestiptv.com
  • News
  • Nintendo Switch
  • Panasonic Smart TV
  • PC Apps
  • Performance Testing
  • Philips Smart TV
  • PS4
  • PS5
  • Python
  • QA Certifications
  • QA Leadership
  • QA Team Skills
  • Quality Assurance
  • Reddit
  • Reviews
  • Roku
  • Samsung Smart TV
  • Screenshot
  • Selenium Tutorials
  • Sharp Smart TV
  • Skyworth Smart TV
  • Smart TV
  • Soft Skills For Testers
  • Software Testing Templates
  • Software Testing Tools
  • Software Testing Training
  • Sony Smart TV
  • Sports
  • Streaming Apps
  • Streaming Devices
  • Tech News
  • Test Management Tools
  • Test Strategy
  • Testing Best Practices
  • Testing Concepts
  • Testing Methodologies
  • Testing News
  • Testing Skill Improvement
  • Testing Tips and Resources
  • Toshiba Smart TV
  • Tutorials
  • Twitch
  • Types of Testing
  • Uncategorized
  • Vizio Smart TV
  • VPN
  • Web Testing
  • What is
  • Xbox
©2023 Iptv Assist | Design: Newspaperly WordPress Theme