Dependencies makes easy to manage external libraries of a project , rather than adding jar files manually. Maven can manage dependencies for a project by downloading and adding jar files to java path.
Dependencies play a crucial role in selenium testing automation as they determine which tools and libraries available for interacting with web browsers and test execution.
Depending on your testing needs, you can integrate selenium with testing frameworks like JUnit ot TestNG.
Here,we can see some dependencies and their uses in maven project.
Selenium Java: Selenium is an open source tool
Below dependency provides support for the automation of web browsers.It supports in cross-browser testing .Selenium java integrates with testing frameworks such as JUnit and TestNG.It helps in handling dynamic webelements .It also helps in parallel testing.
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.17.0</version>
</dependency>
Cucumber-Java:
Below dependency useful for writing and executing cucumber feature files.It helps in implementing behaviour driven development(BDD).
you can update latest version number in your pom.xml
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.15.0</version>
</dependency>
Cucumber JUnit:
This will allow tests to be executed in JUnit
you can update latest version number in your pom.xml
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.15.0</version>
<scope>test</scope>
</dependency>
Cucumber TestNG:
Below dependency used to integrate cucumber based BDD tests with TestNG testing framework.
you can update latest version number in your pom.xml
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>7.15.0</version>
</dependency>
TestNG:
Below dependency makes more powerful easier way of using the functionalities.It also supports test configured annotations.you can update latest version number in your pom.xml
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.9.0</version>
<scope>test</scope>
</dependency>
Apache Log4j:
Below dependencies allows easy configuration.It supports various logs implementation and integration.These dependencies helpful in setting up logs.
you can update latest version number in your pom.xml
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.22.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.22.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.22.1</version>
</dependency>
WebDriverManager:
Below dependency used for setting up a webdriver binaries required for test automation browsers and also making test automation more efficient. This dependency gives your java code to open browsers . This is helpful in setup for browser drivers needed by selenium webdriver.It automatically downloads correct latest version of browsers.
you can update latest version number in your pom.xml
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.7.0</version>
</dependency>
Apache POI:
Below dependencies provided by Apache foundation which is a collection of different jav libraries.These dependencies gives facility to read and write data from excel.
you can update latest version number in your pom.xml
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.0</version>
</dependency>
<dependency>
<groupId>org.jxls</groupId>
<artifactId>jxls-jexcel</artifactId>
<version>1.0.9</version>
</dependency>
Fasterexcel-reader:
Below dependency useful in reading data from excel file very quickly and you can update latest version number in your pom.xml
<dependency>
<groupId>org.dhatim</groupId>
<artifactId>fastexcel-reader</artifactId>
<version>0.15.3</version>
</dependency>
Commons- IO:
Below dependency simplifies file input output stream operations.
you can update latest version number in your pom.xml
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
</dependency>
Extent Reports:
Below dependency useful for generating extent reports
you can update latest version number in your pom.xml
<dependency>
<groupId>tech.grasshopper</groupId>
<artifactId>extentreports-cucumber7-adapter</artifactId>
<version>1.14.0</version>
</dependency>
JSON Dependencies:
Below dependency useful in read and write data from json file.It includes with Jackson library,GSON library,JSON Simple library.
you can update latest version number in your pom.xml
Jackson Library:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.17.1</version>
</dependency>
GSON Library:
GSON is a java library that can be used to convert java objects in json representation.It can also used to convert json string to a java object.
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
</dependency>
JSON Simple Library:
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple --> <dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
Pico-Container:
Below dependency supports dependency injection.It supports various configuration options
you can update latest version number in your pom.xml
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>7.18.0</version>
</dependency>
Maven Compiler Plugin:
The compiler plugin used to compile the sources of a project.
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</dependency>
Maven Surefire plugin:
This plugin essential tool for automating testing process.
By default sure fire executes all test classes
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
Testng.xml:
It is a key component for specifying
How tests should be executed
Including which classes,methods
Group of tests to include or exclude
How to run tests in parallel
How to handle dependencies between tests.
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
For reports some of the plugins will be added in test runner,will mention those plugins here
Below plugin helpful in generating Cucumber HTML detailed reports which can be easily shared and viewed.
plugin = { "pretty", "html:target/result.html",
"io.qameta.allure.cucumber7jvm.AllureCucumber7Jvm",
Below plugin helpful in generating Extent HTML reports, this should be configured in your @cucumberoptions annotation plugin attribute .Adjust configuration and path as needed based on your project.
"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:" },
Conclusion:
Here mentioned some of the dependencies plugins taken in creating maven project , Based on Cucumber BDD Framework. Dependencies reduces manual effort in configuring browsers and managing test execution . choose dependencies based on your project needs .Hope this was useful. Happy reading and keep learning.
Comments