Using Selenium test scripts is easy but when it comes to build management and Continuous integration, Selenium alone is not that powerful.That’s why we integrate Maven and Jenkins with Selenium
You need to take help of other tools to integrate Continuous integration and deployment. This is exactly why Maven and Jenkins are needed.
What are Maven and Jenkins?
Jenkins is an open source continuous integration tool and it is cross platform which can be used on Windows, Linux, MAC and Solaris environment.
Jenkin will monitor a job which can be SVN checkout, cron or any application state.
It then fires an action when a particular step occurs in a job. Maven is a build management tool which makes the build process very easy.
With the help of maven you can define your project structure, dependencies and builds.
With the help of pom.xml you can define all the dependencies which would ease the process of build.
Maven automatically download the necessary files from maven repository and place them in. /m2 repository. Hence, we require Maven and Jenkins with Selenium.
Advantages of Using Maven and Jenkins
Steps to Install Maven with TestNg in Selenium
You should have Eclipse installed in your machines. Along with that, you need m2eclispe plug-in which you can download from Eclipse marketplace.
You can go to Eclipse marketplace and then search Maven and the first plug-in which will come, you can download that.
Let’s see how to create a Maven project.
1. mvn clean
2. mvn compile
3. 0mvn test // for all tests to be executed.
4. mvn -dtest // for a particular test to be executed.
Steps to Install Jenkins with Selenium
Let’s see how to configure Jenkins with Selenium so that client and all technical people would be able to handle a single server for all test results.
1. Click here and download correct package for your operating System. Then you can install Jenkins Unzip Jenkins to a specific folder and run its exe file.
2. When you are done with installation of Jenkins you have to fire a command in cmd to start your jenkins server.
java -jar jenkins.war
3. It will automatically host the server on 8080 port but if you don’t want it to run on 8080 port then you can specify the port number along with the command.
4. After that is done. You can visit https://localhost:8080 You can do the installation of necessary plugins. Then you can click on New Item and then select the Maven project.
5. Then you can click on Ok and a new job will be created with the name specified by you.
6. Now go to Manege Jenkins and then Configure Systems. Configure Maven and JDK there and go to Build Section and enter their full path of your pom.xml.
7. Now click on Apply. On the main page, click on “Build Now” link. Maven will automatically execute the test. After the build is done click on your project name.
8. In the left sticky bar you can see the execution history. You can click on the latest results to view the test results.
9. Even you cans schedule the test cases with Jenkins. You have to go to modify the configuration and there enter “Build Periodically” and enter the time in the manner like “0 23 * * *”. It will trigger everyday at 11 pm.
This way you can make your build process easier easy and can do continuous integration with Jenkins. This will increase the time efficiency and will help in better management of your test suite.
Recommended For you : 15 Top Selenium WebDriver Commands For Test Automation