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

Integration of Jenkins with Selenium WebDriver: Step-by-Step Tutorial

Posted on March 26, 2023

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

Step by step guide to Setup and Configure Jenkins with Selenium:

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

Our previous tutorial in the DevOps Series explained about Ansible Roles and Integration with Jenkins in DevOps.

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 )

 

Jenkins is an open source tool written in Java. It provides continuous delivery and continuous integration service for software development.  It automates your manual task of code deployment process from development box – QA – Stage – Production.

Suggested Read => Precise DevOps Training Tutorial Series

Jenkins supports many plugins which you can integrate such as Git, SVN, build pipeline and many more. 

The basic functionality of Jenkins is to execute a predefined list of steps on the basis of time and some events.

For example, when you want to base the execution on time you can run a job every 20 minutes or if you want to base it on an event you can do so after a new commit in a Git repository.

Integrat Jenkins with Selenium WebDriver

 

In this article we covered the below points:

  • Jenkins usage and integration with selenium
  • Creating a batch file and using it Jenkins
  • Scheduling Jenkins job and added email notification
  • And running selenium script from the command line

Advantages of using Jenkins are:

  • It is a cross-platform and can be used on Windows, Linux, Mac OS, and Solaris environments
  • It is a free and open source tool
  • Widely used and well documented
  • Integration with a wide variety of tool and technologies

Apart from Jenkins, we have many more tools in the market such as:

  • Anthill
  • Bamboo
  • Cruise Control
  • Team City and many more.

What You Will Learn:

  • Jenkins usage and integration with selenium
  • Creating a batch file and using it in Jenkins
  • Scheduling  Jenkins job
  • How to add email notifications
  • Running Selenium script through command line
  • Conclusion

Jenkins usage and integration with selenium

Follow the below step-by-step procedure to use Jenkins with Selenium

Step #1:

Download Jenkins from the official website of Jenkins – Jenkins. Download the latest .war file. Jenkins can be started via the command line or can run in a web application server.

Refer to the below steps for the execution through the command line:

1) Open the command prompt and type java –jar and enter the path of a .war file

(Note: Click on any image for enlarged view)

java –jar

2) Press enter and check if your Jenkins.war file started to run and check the status information on the command prompt console.

It should show – Jenkins is fully up and running

Jenkins is fully up and running

3) Now check whether your Jenkins is ready to use; by default, it uses port 8080.

Type “http://localhost:8080” in the browser and press enter. It will show you Jenkins UI.

Jenkins UI

It will load the Jenkins dashboard empty by default. I created some Jenkins job in the above screenshot as an example and hence, it did not load empty.

Step #2:

To use Selenium with Jenkins you need to configure Jenkins with Selenium.

Follow the below steps:

  • Go to Jenkins dashboard
  • Click on manage Jenkins
  • Click on configure Jenkins
  • Click on JDK installation – In JDK name section enter the name, under Java Home section – give your java path

JDK installation

The radio button, Install automatically is checked by default. You need to uncheck it because it will automatically update with the new Java version and there might be a possibility that Selenium doesn’t support the new Java version. It is better to uncheck it. Now click on apply and save.

Your Jenkins is configured with Selenium and is now ready to be used with Selenium. Both Jenkins and Selenium code is written in Java. Hence, if you give the Java path then internally it will communicate and process your job.

Step #3: 

Now, create a Selenium script and a TestNG XML file. This TestNG XML file will be required for creating a batch file and we will use that batch file in Jenkins. Refer below TestNG code:

Refer below TestNG code:

TestNG code

package session_2;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

public class jenkins_demo
{

@Test
publicvoidtestgooglrsearch(){

WebDriver driver = newFirefoxDriver();
//it will open the goggle page
driver.get("http://google.in"); 
//we expect the title “Google “ should be present 
String Expectedtitle = "Google";
//it will fetch the actual title 
String Actualtitle = driver.getTitle();
System.out.println("Before Assetion " + Expectedtitle + Actualtitle);
//it will compare actual title and expected title
Assert.assertEquals(Actualtitle, Expectedtitle);
//print out the result
System.out.println("After Assertion " + Expectedtitle + Actualtitle + " Title matched ");
 }
}

Output: Before Assertion GoogleGoogle

After Assertion, GoogleGoogle Title matched

PASSED: testgooglrsearch

 Create a TestNG xml file, refer below code:

TestNG xml file

Step #4:

Go to your project root directory and create a library folder.

Refer the screenshot below:

library folder

Now, add all your jar files which are required for running your Selenium script:

add all jar files

Step #5: 

Creating a batch file and using it in Jenkins

Create a batch file by following the below steps:

1) Open the notepad and type-: Java –cp bin;lib/* org.testng.TestNG testng.xml

By doing this, Java –cp will compile and execute a .class file which is located at bin directory and all our executable jar file is located at lib directory and we are using a TestNG framework so specify org.testng.TestNG. Also, specify the name of xml file which will trigger the expected TestNG script.

2) Save the file with .bat extension and check the type of file. It should be “windows batch file”. To cross-check whether the batch file is created properly, double-click the batch file and it will execute the code. Refer the below code of batch file:

windows batch file

Step #6:

Next, we need to add a batch file in Jenkins.

For adding the batch file follow the below steps:

1) Go to the Jenkins dashboard, create a new job in Jenkins

2) Click on a new item and enter the item name and check the freestyle project radio button

a new job in Jenkins

3) Click Advanced options

advance options

4) Click on use custom workspace and give your Selenium script project workspace path: “E:Automation_workspaceDemo-testNG”

use custom workspace

5) Then go to Build and Select an option from the drop-down box, execute your build through Windows batch command

6) And give your batch file name here – “run.bat”

run.bat command

7) Click on apply and save

8) Click on the build now and see the build result on console output

console output

So far we have learned:

  • How to start Jenkins
  • How to configure Jenkins with Selenium
  • Creating your batch file and executing it through Jenkins.

As you all are aware Jenkins is a very powerful tool which is mainly used for running nightly builds. Hence, we shall now learn how to schedule your build and send email notifications to the concerned team.

Scheduling  Jenkins job

For scheduling you batch file, perform the below steps:

  • Go to dashboard and click on the Jenkins job
  • Click on configure and then on the advanced  option
  • Then go to Build triggers and select Build periodically option and enter your cron job pattern

Build triggers

  • To understand cron job pattern follow this wiki link

I entered * * * * * which means it will run my job every minute

  • Click on apply and save

There is no manual intervention. After scheduling the script, it will run at the scheduled time.

How to add email notifications

Next, we will cover how to add email notifications.

Refer the below steps:

  • Go to the section ‘Manage Jenkins’
  • Click on configure system
  • Select Email notification

Email notification

  • Give your SMTP server address. I am using Gmail, as I can’t mention my official server address. To know your official server address, contact your network support team
  • I entered SMTP server name = smtp.gmail.com
  • Click on the advance link and check Use SMTP Authentication check box
  • Provide username, password and SMTP port number; it is 465 for Gmail. Check charset and make sure it is = UTF-8

Use SMTP Authentication

  • Check your email configuration settings by clicking on Test configuration button.
  • So, whenever the build passes or fails you will get the email notification.

Running Selenium script through command line

We will now see how we can run Selenium script through command prompt. This part has nothing to do with Jenkins. I am sharing this to give extra insights on Selenium.

Follow the below steps:

  • Open your command prompt and go to your project base path

project base path

  • Set class path for your script file; which means we are specifying that our binary and library files are stored in this location

E:Automation_workspaceDemo-testNG > set classpath = E:Automation_workspaceDemo-testNGbin;E:Automation_workspaceDemo-testNGlib*;

Set class path

  • Execute your testng.xml file by typing the command – java org.testng.TestNG testng.xml

Execute your testng.xml file

  • When you press enter your script will start executing and you can see the test result in the UI

Sometimes while executing your script you may face error which says, “Could not find or load main class org.testng.TestNG”

face error

Then you need to close your command prompt and again set your classpath as mentioned above and repeat the same steps. Your error will get resolved and the script will run.

Conclusion

Integration of Jenkins with selenium provides you to run your script each time there is any change in software code and deploy the code in a new environment. With Jenkins, you can save execution history and test reports.

In short, Jenkins is very useful when you have test cases ready and you want them to run using a single click. We can create or schedule a build to run the test cases using a batch file.

Further reading => Integrate Selenium with Maven project

Note: This tutorial is a part of Selenium as well as DevOps tutorial series. Click the below link for previous and next tutorials from the DevOps series.

PREV Tutorial | NEXT Tutorial

Feel free to post your queries in the comments section below.

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

  • IPTV List: Best iptv lista 2023
  • IPTV Premium: Best Premium IPTV Service Provider List And Benefits
  • Nikon IPTV Review: Over 10,000 Live Channels for $12/Month
  • Iptvwings. Com Review: +18000 Live IPTV Channels ,+70000 Movies, +40000 TV show For $15/1 month
  • IPTVUNO Review: More Than 16000 Live TV channels, 55,000 Movies & VOD For $15/Month

Recent Comments

  1. IPTV List: Play lista iptv 2022 - Iptv Assist on Best IPTV Player in 2023 for Watching Live TV
  2. Cola IPTV – Over 18,000 Live Channels for $12/Month - Iptv Assist on FileLinked – How to Install on Firestick/Fire TV and Android Devices
  3. Cola IPTV – Over 18,000 Live Channels for $12/Month - Iptv Assist on 50+ Best IPTV Service Providers for Streaming Live TV 2023
  4. XoomsTV IPTV – Over 11,000 Channels & VOD for Under $13/Month on Best VPN for IPTV in 2023 and How to Install on Firestick/Android
  5. Voodoo Streams IPTV Review – Over 12,000 Channels for $11/Month - Iptv Assist on Dynasty TV IPTV Review – Over 6,000 Channels for $10/Month

Archives

  • March 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