How To Set Up A Seamless Framework Using Selenium Maven And Jenkins?

Setting Up A Seamless Framework Using Selenium Maven And Jenkins

Jenkins is known to be one of the best open-source technology. It has established itself as one of the top open-source solutions for managing builds and continuous integration. We will learn how to set up a fundamental foundation for this utilizing widely used, well-known Selenium Maven tools, some of which may have previously been employed when developing the tested application.

Jenkins has surpassed other open-source solutions in its capacity to support continuous integration, build management, and — most importantly for this blog post — the ability to execute automated tests without requiring human intervention. However, there is still some work to be done to set up the entire environment before we can just sit back and watch how our automated tests extensively check every triggered build.

Sailing smoothly with Selenium Maven: Setting the stage for stress-free testing.

Overview of Jenkins and Selenium Maven

A well-liked build automation tool for Java projects is called Maven. Java libraries and plugins are dynamically downloaded from the Maven 2 Central Repository, which is a benefit of utilizing Maven.

The project’s pom.xml file contains the dependencies and other crucial build-related data. The dependencies are downloaded, saved locally (in a.M2 repository), and employed for build creation simultaneously. As a result, the build process is made simpler because any new project dependencies simply need to be put in pom.xml rather than manually obtaining and installing packages.

What do you mean by Maven?

Maven is considered to be a potent project and build management tool. Its configuration includes project information and details about the project, among other things.

Do you know why people prefer using Jenkins and Selenium?

Jenkins has the capability to schedule your tests to run at a designated time, while Maven, on the other hand, is supported by Jenkins for project building and testing during the continuous integration process.

How to install Maven and use Selenium with it

To speed up the Selenium Maven build process and generate pom.xml files, we must install the m2eclipse plugin to Eclipse.

Step 1: From the Eclipse Main Menu, choose Help | Install New Software in the Eclipse IDE using Selenium.

Step 2: Type the URL into the Install dialogue box.

Step 3: Press the Next button to complete the installation.

Configure Maven in Eclipse –

After installing the m2e plugin, we must build a Selenium Maven project:

Step 1) Open the Eclipse IDE and choose File | New | Other from the Eclipse menu to start a new project.

Step 2) Click Next after choosing Maven | Selenium Maven Project in the New window.

Step 3) Click Next after selecting Create a basic project in the New Maven Project window.

Step 4) Type “WebdriverTest” in the “Group Id:” and “Artifact Id:” fields and press “complete.”

Step 5) Eclipse will create the following structure for the Selenium

Selenium WebDriver Test –

Step 6) Use the menu when you right-click on JRE System Library to choose the Properties option. Just remember that all the files are selected, so there is no space for any error, or it will cause an issue in the execution.

Step 7) From Project Explorer, choose pom.xml. The Editor section will open with the pom.xml file.

Step 8) Update the node’s pom.xml file to include the Selenium API, Maven, TestNG, and Junit dependencies:

Step 9) in this step, the users must create and select a New TestNG Class. You must type “example” and “NewTest” into the Name: textbox. After this, you are supposed to press the Finish button.

Step 10) There will be a new text class created with the help of Eclipse.

Convert to TestNG from the context menu –

  • The Eclipse will produce testng.xml, which states that only one test with the Name NewTest has to be executed.
  • Update the project and confirm that the file can be found in the Package Explorer tree (right-click on the project – Refresh).
  • You must now execute the test using this testng.xml.
  • Select the project, enter testng.xml as the Suite in the Run Configurations box, then click Run to launch TestNG. We also need to include

Maven-compiler-plugin to pom.xml using the maven-surefire-plugin testing.xml.

  • In this case, a plugin is utilized to create test reports and set up testing.xml for TestNG tests.
  • The code is compiled with the aid of the maven-compiler-plugin using the specific JDK version.

Tests in the Maven lifecycle –

Ensure the construction project is successful once you have completed the process and maven has run the process. Instructions for setting up Jenkins to run Maven with TestNG and Selenium

  • Visit and download the appropriate package for your operating system. Set up, Jenkins.

  • Unzip Jenkins to the destination location.
  • At the very end, click the Install button.
  • After the installation, open a browser window and go to the Jenkins Dashboard (the default address is http://localhost:8080).
  • To create a CI job, click the New Item option.
  • Press the OK button. A new job named “WebdriverTest” will be created in the dashboard of Jenkins

Navigate to the New Job > Build area.

Enter the whole path to pom.xml in the Root POM textbox.

“Clean test” should be entered under Goals and Options.

Press the Apply button.

  • In the next step, choose the Build Now option on the WebdriverTest project page.
  • The project will be built using Maven. TestNG will subsequently execute the test cases.
  • After finishing the build process, choose the WebdriverTest project in Jenkins Dashboard.

Bottom Line

Now that you have completed the setup process for Selenium Maven, you need to execute it and check whether it is working. If you need more confidence in setting up a continuous framework using Selenium, you can contact our experts and get their assistance.

The following two tabs change content below.


Co-Founder & Director, Business Management
AutomationQA is a leading automation research company. We believe in sharing knowledge and increasing awareness, and to contribute to this cause, we try to include all the latest changes, news, and fresh content from the automation world into our blogs.