Selenium Integration with Jenkins – 2 Most Easy Methods
Let’s start this blog by considering ‘Why testing is important?’ Testing is necessary because a flaw or failure can result from a human error at any point along the Software Development Life Cycle (SDLC). Depending on the consequences of the miscalculation, the outcomes are categorised as minor and catastrophic. Automation Testing revolutionised the software testing field replacing long mundane manual tasks.
Selenium is the most important automation testing tool used in the top most IT companies. Selenium Integration with Jenkins enables you to run your script each time software code is changed and to deploy the code to a new environment. You can store test results and execution history using Jenkins. Scroll down further and find the two different methods to integrate Jenkins with Selenium!
Selenium Integration with Jenkins
1. Download Jenkins
Step 1: Go to the Jenkins official website and click the download button to start the installation process. Here is a comprehensive explanation of the installation procedure.
Step 2: Download Jenkins.war and save it in the desired location.
Step 3: Launch the command prompt and go to the folder where the war file is located.
Step 4: Type java -jar Jenkins.war into the command line. The Jenkins server would start as a result.
Step 5: By default, Jenkins would start on port 8080. If the port is not available, the command below can be used to define an alternative port.
The command above can be used to start the Jenkins server and define any open ports. A secret password will be produced when Jenkins is first created and printed at the end of the terminal.
The secret password for installing Jenkins on your workstation is located in the white-shaded area. Jenkins may be fully up and running when the installation is complete, according to the console message.
Step 6: Launch your browser and go to localhost. The port number would be 8080 by default. The Jenkins setup page, which is used to create the admin account for Jenkins, will now be launched.
Step 7: On the setup page, enter the secret password that was produced and presented before and then click Continue.
Step 8: The secret password must be entered, and a notification will pop up to install plugins. Selecting “Install suggested plugins” will install a selection of frequently used plugins if you are unsure of the plugins you want. However, if you know the necessary plugins, you can choose the option to install plugins and then select the appropriate ones. Once you initiated the process, the plugins would have been downloaded and set up.
Step 9: Followed by the successful completion of the plugin installation, you will be prompted to create an administrator account by offering a username, password, and email address. The Jenkins dashboard will be displayed after the admin profile has been set up. Now that Jenkins has been installed and configured on localhost, you may see the Jenkins dashboard.
2. Selenium Integration with Jenkins – Method 1
Step 1: Click New Item in the Jenkins dashboard to start a new project. Give the project a name, then select the Freestyle Project option. Hit ‘OK’.
Step 2: Type the project description in the Description box under the General section.
Step 3: Choose ‘None’ under Source Code Management.
Step 4: To schedule the jobs, choose the appropriate choice from the provided list. Now that the jobs are scheduled let’s define their duration. There are a few guidelines that must be followed in order to fix the duration.
- MINUTE – 0 to 59 Minutes Within the hour
- HOUR – 0 to 23 Hours of the day
- DOM – 0 to 31 Days Of Month
- MONTH – 1 to 12 Months
- DOW – 0 to 7 Days Of Week (where 0 and 7 are Sundays)
Take the Selenium Training in Chennai to learn more about such guidelines in the integration and functionalities of selenium in the software testing field.
Step 5: Create a project using Selenium WebDriver and TestNG to execute the tests.
Step 6: Create a TestNG.xml file.
Step 7: Create a separate folder in the project folder for each dependency. With the content below, create a bat file.
bin;lib/* org.testng.TestNG ava -cp TestNG.xml
Give a precise name to the TestNG.xml file you made in your project.
Step 8: Choose the project we initially created in the Jenkins dashboard. To configure, click. Click ‘Advanced’ in the General area, then select ‘Use custom workplace’. Indicate the test project’s route.
Step 9: Click the ‘Add Build Step’ selection box in the Build section and choose the ‘Execute Windows batch Command’ option. Indicate the name of the bat file that was made in step 7 here.
Step 10: To apply all the changes to your Jenkins project, click ‘Apply’ and then ‘Save’. As soon as you click Build, the Jenkins project’s tests will start to execute.
3. Selenium Integration with Jenkins – Method 2
Maven, an automation tool, helps us to add and manage all the dependencies in a single pom.xml file. Users can reuse the same dependencies across many projects due to this. It is unnecessary to manually add each dependency as a JAR file to the project by adding the dependencies in a pom.xml file, which automatically downloads and adds the dependencies to the project.
Therefore, the DevOps approach may be used, and Continuous Integration could be achieved in the project by combining Maven, Jenkins, and Selenium WebDriver. This is the second method of Selenium integration with Jenkins. The method starts with downloading the Maven tool. You can also take the Selenium Training in Bangalore to learn about the installation of Maeve and its integration with Selenium and Jenkins in detail.
Step 1: Download Maven from the vendor’s home page.
Step 2: Add the MAVEN HOME system variable.
Step 3: Configure the route so that it directs users to the maven directory’s bin directory.
Step 4: In the command prompt, execute the mvn -version to confirm that Maven has been successfully installed.
Step 5: Create a maven project and include all of its dependencies in the pom.xml file.
Selenium Integration with Jenkins and Maven
Step 1: Launch the Jenkins server.
Step 2: Launch a browser and go to the port and localhost where Jenkins is executing.
Step 3: On the dashboard, select ‘New Item’.
Step 4: Type the project name and choose ‘Maven Project’ as the project type.
Step 5: Press ‘Ok’. Now, you can see in the dashboard that work has been successfully established.
Step 6: Click ‘Configure’ after selecting the project.
Step 7: Submit the full path to your pom.xml under the Build section. Enter the command ‘clean test’ in the Goals and parameters box.
Step 8: ‘Apply’ and ‘save’ after clicking.
Step 9: Click ‘Build now’.
Step 10: The build will now be executed, and the results will be shown when it has successfully finished. Click the console output to see the entire logs.
Recently, many IT companies are shifting their software testing methods to automation testing, realizing the most valued question, ‘Why Testing is Important?’ Employers cannot belittle the tremendous advantages gained from automation testing to produce effective software for consumers. Enroll in the Selenium Training in Chennai and art the skill of automation in the software testing field.