Monday, 22 February 2021

Maven and Jenkins Integration with Selenium? How to Run Selenium Tests in Jenkins Using Maven? Run Selenium suite from command line?

 

 

How to send email notification with groovy script in Jenkins pipeline?

Pipeline Script Fundamentals

Click Here:   DevOps Related Posts

Below is part-1 for Integration of pom.xml with TestNG suite and executing the same from command prompt and Jenkins CI-CD job, In the next part we will cover Scheduling of NIGHTLY JOB.

This post will help to answer below:

How to run testng.xml from Jenkins, run testng xml from command line, how to run selenium tests in jenkins pipeline, can we integrate testng and jenkins with maven, run selenium maven project from command line

SDET Interview Question and Answers.  

Jenkins Interview Questions and Answers

Appium Interview Questions and Answers

Selenium Interview Questions and answers

GIT Interview Questions and Answers

Let's have a quick introduction about Maven, Jenkins and Selenium

Maven: It is used as a build management tool, which can simplify the build process and make jars more easily available. To create a Maven project for selenium refer the link HERE which has the pom.xml for setup

Jenkins: It is an open-source continuous integration tool. It can be used on Windows, Linux, MAC and Solaris environments. Click this link HERE to learn more about Jenkins

Selenium: This is an open source umbrella project for a range of tools and libraries aimed at supporting browser automation.

Why to Use Maven & Jenkins:

Whenever a new deployment is made, Jenkins will keep an eye on it and run a smoke test against the latest build. Once the build is passed, it will be deployed in the build production environment. It is difficult to run all the test cases by the time you reach the office. If you know that your test or regression suite will take almost 12 hours to execute then you can have a nightly build run on Jenkins, which will run the test cases during the night time so that by the time you reach the office, you can get the latest test result without wasting any more time.

Using Maven in your project removes the hard coding of jars.The Build process will become very easy with Maven build management tool.Updating hard coding jars is a hectic process. It’s better to update the version number in pom.xml so that jars can be updated on the go. You don’t need to worry about deleting the old jar and getting the latest jar. If the team is big then you need a common structure to share the project structure. It’s easy to share the artifact id and version id so that people in the team can clone the project.

Prerequisites for running :

  1. Automation suite in testng xml
  2. Java should be installed.
  3. Selenium
  4. Maven should be installed.
  5. Using TestNG framework for Test Cases
  6. Jenkins server access

Selenium-Automation suite in TestNG xml

For Execution purposes, let's create a sample project with below code:




For the above code, kindly check the GOOGLE DOC.

Now we have to add this test class to the TestNG suite, so lets create a TestNG.xml file which will call above class:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Automation Test Suite">
  <test name="VerifyTitle">
      <classes>
        <class name="com.task.automation.test.SeleniumMavenJenkinsSetup"/>
      </classes>
  </test>
</suite>


 STEP-1

As of now we have created a sample Selenium script and added that to our automation suite in TestNG.xml.

Our next step would be Integrate TestNG.xml suite with pom.xml. To do that we have to add the below section inside pom.xml and mention the path of TestNG.xml suite inside(resources\testNG_xml\SmokeSuite.xml)

 
<suiteXmlFile> use this particular tag in pom.xml:

<configuration>
<suiteXmlFiles>                             
  <suiteXmlFile>resources\testNG_xml\SmokeSuite.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>

To get the entire pom.xml with dependencies required in Selenium Automation Framework

refer below link: Click Link Here For pom.XML

 STEP-2

Go to your Automation project path and open command prompt, as shown below project name is “Task” and we have opened cmd @project location:

 



STEP-3

Enter maven goal for the test as: "mvn clean test" in the command prompt and hit ENTER:

 



STEP-4

Go to Jenkins, click on New Item as shown in below screenshot:


 ****************************************************************

WANT TO KNOW HOW to integrate GRADLE + TESTNG + JENKINS CI-CD , click on below link for entire steps with screenshot:

How to run test automation TestNG suite with gradle from jenkins job? Jenkins Integration with Gradle and TestNG.xml suite?Run TestNG suite with Gradle? 

******************************************************************

STEP-5

Provide the name for the job and select Maven Projectàclick on OK button:



STEP-6

Go to BuildèSelect Invoke top-level Maven targetsà Enter the Goals as “clean test” and put the pom.xml path of your project in “POM” section as shown below. 

Now you just need to Click on the SAVE button.


 

********************************************************

TO get more Framework Design and Components, Click The Link Below:

Framework Design Tips & Interview Question-Click Here

**************************************************

Step-7

To Run the Suite Click on the Build Now button as shown below:




 

NOW we are done with Part one where we have learned on the integration of Selenium Automation Suite in Testng.xml with pom.xml. 

Our next part is now how we can schedule the Jenkins job created to run the automation suite:Click Here For Schedule Job

 


****************************************

TOP 15 BDD - CUCUMBER Interview Q&A


************************************************

✍️AUTHORLinkedIn Profile

************************************************

Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

For more details whatsapp : https://lnkd.in/dnBWDM33

*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

API Testing Interview Question Set:

https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

DevOps Interview Q&A:

https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

Kubernetes Interview Question Set

https://automationreinvented.blogspot.com/search/label/Kubernetes

Docker Interview Question Set

https://automationreinvented.blogspot.com/Docker

Linux Interview question Set

https://automationreinvented.blogspot.com/search/label/Linux

Automation Testing/SDET Framework Design

https://automationreinvented.blogspot.com/search/label/FrameworkDesign

Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java

GIT Interview Question Set:

https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

Coding Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Coding%20Questions

Mobile Testing Interview Question Set:

https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

Python Interview Question Set for QAE - SDET - SDE:

https://automationreinvented.blogspot.com/search/label/Python


 


No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...