Execute Selenium build using Jenkins

How to execute selenium build using Jenkins?

We can execute selenium test cases in Jenkins by multiple ways. Please refer following screenshot where we can see multiple options to execute the build.
Jenkins with selenium
In this chapter, we will execute our test cases by using Windows batch command.


Step 1: First of all, you have to set the classpath and then to create a batch file. Please see the following instructions to do this.

1) Open your project structure. In my case it looks like below.
2) Open command prompt and set the classpath.

While setting classpath, we need to set the path of bin folder and libs folder (inside libs we have all libraries)

Home directory \> set classpath=C:\Users\Learn-automation\bin;C:\Users\Learn-automation\libs\*;

Note- Please make the changes as per your project structure

3) Open notepad and type the following command and save it as run.bat file

java -cp bin;libs/* org.testng.TestNG testng.xml
Jenkins with selenium

Step 2: Create a job in Jenkins to execute our build.

1) Open Jenkins on browser (http://localhost:8080). Click on the 'New Item'.


Jenkins with selenium


2) Specify the Job-Name, select 'Build a free-style software project' and Click on 'OK' button.
Jenkins with selenium

3) Navigate to Advanced Project Options --> Click on checkbox 'Use custom workspace' --> Inside directory, we will specify the project home directory.


4) Add Build step --> Click on Execute Windows batch command.

Jenkins with selenium

5) Specify the batch file which we created and click on Apply and save.

Jenkins with selenium


Step 3: To run the Build --> Click on 'Build now'  option.


Jenkins with selenium

Step 4: Check Build history and Console output and verify the output


Jenkins with selenium




<-- Previous || Next -->

3 comments:

  1. Can you please help me out that i never had a successful build.
    Always a failure build.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete