Trending September 2023 # Maven &Amp; Jenkins Integration With Selenium Tutorial # Suggested October 2023 # Top 13 Popular | Dacquyenphaidep.com

Trending September 2023 # Maven &Amp; Jenkins Integration With Selenium Tutorial # Suggested October 2023 # Top 13 Popular

You are reading the article Maven &Amp; Jenkins Integration With Selenium Tutorial updated in September 2023 on the website Dacquyenphaidep.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested October 2023 Maven &Amp; Jenkins Integration With Selenium Tutorial

What is Jenkins in Selenium?

Jenkins is the leading open-source continuous integration tool developed by Hudson lab. It is cross-platform and can be used on Windows, Linux, Mac OS and Solaris environments. Jenkins is written in Java. Jenkin’s chief usage is to monitor any job which can be SVN checkout, cron or any application states. It fires pre-configured actions when a particular step occurs in jobs.

Important Features of Jenkins

Change Support: Jenkins generates the list of all changes done in repositories like SVN.

Permanent links: Jenkins provides direct links to the latest build or failed build that can be used for easy communication

Installation: Jenkins is easy to install either using direct installation file (exe) or war file to deploy using application server.

Email integration: Jenkins can be configured to email the content of the status of the build.

Easy Configuration: To configure various tasks on Jenkins is easy.

TestNG test: Jenkins can be configured to run the automation test build on Testng after each build of SVN.

Multiple VMs: Jenkins can be configured to distribute the build on multiple machines.

Project build: Jenkins documents the details of jar, version of jar and mapping of build and jar numbers.

Plugins: 3rd party plugin can be configured in Jenkins to use features and additional functionality.

Why Jenkins and Selenium?

Running Selenium tests in Jenkins allows you to run your tests every time your software changes and deploy the software to a new environment when the tests pass.

Jenkins can schedule your tests to run at specific time.

You can save the execution history and Test Reports.

Jenkins supports Maven for building and Testing a project in continuous integration.

What is Maven in Selenium?

Maven is a powerful project / build management tool, based on the concept of a POM (Project Object Model) that includes project information and configuration information for Maven such as construction directory, source directory, dependency, test source directory, Goals, plugins, etc.

Why Maven & Jenkins

Apache Maven provides support for managing the full lifecycle of a test project.

Maven is used to define project structure, dependencies, build, and test management.

Using pom.xml(Maven) you can configure dependencies needed for building testing and running code.

How to Install Maven and use it with TestNG Selenium

Here is steps to install Maven and use it with TestNG Selenium

Let’s add m2eclipse plugin to Eclipse with following steps:

Configure Eclipse with Maven

With m2e plugin is installed, we now need create Maven project.

Step 5) Eclipse will create WebdriverTest with following structure:

Step 7). Select chúng tôi from Project Explorer..

pom.xml file will Open in Editor section

Step 10). Eclipse will create the NewTest class as shown in the following screenshot:

Step 11) Add the following code to the NewTest class:

This code will verify the title of Guru99 Selenium Page

package example; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Assert; import org.testng.annotations.Test; import org.testng.annotations.BeforeTest; import org.testng.annotations.AfterTest; public class NewTest { private WebDriver driver; @Test public void testEasy() { String title = driver.getTitle(); Assert.assertTrue(title.contains("Demo Guru99 Page")); } @BeforeTest public void beforeTest() { driver = new FirefoxDriver(); } @AfterTest public void afterTest() { driver.quit(); } }

Eclipse will create chúng tôi which says that you need to run only one test with the name NewTest as shown in the following screenshot:

Step 13) Now you need to run test through this testng.xml.

Make sure that build finished successfully.

Step 14). Additionally, we need to add

maven-compiler-plugin

maven-surefire-plugin

testng.xml

to pom.xml.

The maven-surefire-plugin is used to configure and execute tests. Here plugin is used to configure the chúng tôi for TestNG test and generate test reports.

Make sure that build finished successfully.

How to Integration of Jenkins with Selenium WebDriver

Here is steps to Install Jenkins and configure it to Run Maven with TestNg Selenium

Installation

Step 2) Unzip Jenkins to specified folder. Run exe file as shown in following screenshot:

Step 7) Select the Maven project radio button as shown in the following screenshot:

Using the Build a Maven Project option, Jenkins supports building and testing Maven projects.

Step 10) Go to the Build section of new job.

In the Root POM textbox, enter full path to pom.xml

Maven will build the project. It will then have TestNG execute the test cases.

Step 14) The WebdriverTest project page displays the build history and links to the results as shown in the following screenshot:

Scheduling Jenkins for automatic execution.

Scheduling builds(Selenium Tests) is one of the important features of Jenkins where it automatically triggers the build, based on defined criteria. Jenkins provides multiple ways to trigger the build process under the Build Trigger configuration.

Enter 0 23 * * * in the Schedule textbox as shown in the following screenshot. This will trigger the build process every day at 11 p.m.

Using Jenkings without Maven

To run pure TestNg script in Jenkins, enter the following in build

Note: The actual path of lib and bin folder need to add in above command.

After saving the command, Jenkins will build project in predefined time, and this command will be run using TestNG.

Result will be stored in custom report HTML file that can be sent via email with a Jenkin configuration

Output of the code will be

Benefits of using Jenkins

Early issue finding – Bug can be detected in early phase of the software development

Automatic integration – no separate effort required to integrate all changes

Installer – a deployable system available at any point of development

Records – part build records maintained

Support and Plugins: One of the reasons for Jenkin’s popularity is the availability of large community support. Also, lots of ready-made plugins are available which help you expand its functionality.

You're reading Maven &Amp; Jenkins Integration With Selenium Tutorial

Update the detailed information about Maven &Amp; Jenkins Integration With Selenium Tutorial on the Dacquyenphaidep.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!