A discussion about automated testing of Web Applications utilizing Selenium, along with illustrated configuration steps for the Jenkins open source tool.
Selenium is a tool broadly used for automated testing of web applications. One stage ahead, incorporating the selenium Jenkins integration takes it to the next level.
Jenkins is an open source tool written in Java that gives constant conveyance and consistent integration benefits for software advancement. It automates manual tasks of your code arrangement processes from the advancement box – QA – Stage – Production. Jenkins underpins numerous modules which you can coordinate, for example, Git, SVN; manufacture the pipeline and more.
The fundamental functionality of Jenkins is to execute a predefined rundown of steps on the premise of time and a few events. For instance, when you need to construct an execution relying on time, you can run work at regular intervals, or if you need to build an event, you can do so after another confer in a Git repository.
Benefits of selenium Jenkins integration are:
- It is cross-stage and can be used on a Mac OS, Windows, Linux, and Solaris.
- It is a free and open source tool.
- Utilized and all around reported.
- Reconciliation with a wide assortment of technologies and tools.
Step by step guide of Selenium Jenkins integration:
Section 1-Download Jenkins
First Step - Navigate to the official Jenkins Home Page website.
Second Step - Download the Jenkins Java Web Archive (as shown below) and save to desktop or other temporary location.
Third Step - You will next need to execute the "jenkins.war" file that you downloaded.
Section 2 - How to design Jenkins integration with selenium WebDriver:
First Step - Go to the location where you saved jenkins.war
Second Step - Open Command incite known as CMD and explore the project home catalog. Start Jenkins selenium server.
Begin cmd> Project_home_Directory> java – jolt Jenkins.war
Third Step - When the Jenkins server is up and running; you will get a success message.
By default, Jenkins keeps running on Port 8080 so you can explore the URL below for the Jenkins UI (User Interface)
Open the UI by browsing to "http://localhost:8080" in your web browser
Jenkins is now up and running, so we need to configure it with the goal of being able to execute our test case using the Jenkins selenium plugin.
Fourth Step - When Jenkins and selenium are running we are practically done, however, before creating the build, we have to configure Jenkins so that it can recognize different tools like Java, Maven and so on.
Click on > Manage Jenkins
Click on > Configure System
Here we are telling Jenkins that our java is at this location.
Browse to the JDK area and Click on the "Add JDK" button
Uncheck the "Install automatically" check box so Jenkins will just take java previously specified.
Give the name as "JAVA_HOME" and specify the "JDK" path.
In selenium continuous integration of Jenkins, you can arrange an email notice for the client. This is discretionary, but if you need to design Email notifications, then you need to configure some settings.
Refer to the screenshot below to see where you can change the mail server login details - and then click on "Apply"
Once done click on “Apply” and “Save”
Well done, your selenium web driver integration with Jenkins is now configured.
Section 3 - Execute Jenkins selenium web driver TestNG
We can execute test cases with Jenkins in four ways
In this post, we will execute Jenkins with a Windows batch command
First Step - Create a batch file first, then add a similar cluster record to Jenkins
A - To make the batch file, we have to set a classpath of TestNG so that we can execute testng.XML records
Our task structure should resemble the following;
B - Open command provokes and sets the classpath
While setting the classpath, set the way of canister envelope and libs organizer
Home index > set classpath=C: \Users\Learn-automation\bin;C:\Users\Learn-automation\libs\*;
C - Open notepad and write the underneath command and save as .bat document
java – cp bin;libs/* org.testng.TestNG testng.XML
Second Step - Make a task in Jenkins which will execute our build
Use Jenkins UI to program (sort http://localhost:8080)
A - Click on "New Item"
B - Give the Task a Name, select "Build a free-style software project" and Click the “OK” button
C - Navigate to "Advanced Project Options" > Check "Use custom workspace" > In "Directory" provide the project home catalog path
D - The important part now is to determine which "Add Build step" to use > Click on "Execute Windows batch command"
E - In the following area, enter the batch file name you made, and Click on "Apply" & "Save"
Third Step - You can now run the Build > Click on "Build Now"
Fourth Step - Check Build history and Console output to confirm the outcome
Selenium Jenkins integration gives you the ability to run your script each time there is any change in software code and conveys the code in another condition. With Jenkins, you can save execution history and test reports.
So, trigger selenium from Jenkins is extremely valuable when you have test cases prepared, and you need them to run with just a single click. We can make or schedule work to run the test cases using a batch document.