Jenkins is CI (Continuous Integration) tool which will help you to run test in easy manner, In this post, we will talk about Selenium integration with Jenkins and different usage of the same.
Before starting if you have Eclipse , TestNG and if you are using Excel sheets or CSV File, then these jars should be ready.
Selenium integration with Jenkins using Plain Java project
If you are using Maven project and if you want to run maven project using Jenkins then some process will change.
Selenium Integration with Jenkins using Maven project
We will divide this post into Following section
1- Download Jenkins
2- Configure Jenkins for Running Build
3- Execute Selenium build using Jenkins
4- Schedule Jobs in Jenkins to run periodically
Selenium integration with Jenkins
Part 1- Download Jenkins
Step 1- Open your web browser and then Navigate to Below URL
http://jenkins-ci.org this is the official website of Jenkins
Note- Below post will only work if you work with 1.6 version you can download from below url.
(Download 1.654)
https://updates.jenkins-ci.org/download/war/
Step 2- Now download Jenkins.war file and save into desktop or any other location depends on your choice
Step 3- Once download complete. You will get Jenkins.war file that we need to execute
Now let’s navigate to another section
Part 2-How to configure Jenkins for Selenium
Go to the location where Jenkins.war is available. In my case, I kept in my project home directory
Step 2- Open Command prompt knows as CMD and navigate to project home directory and Start Jenkins server
Start- cmd> Project_home_Directory> java -jar Jenkins.war
Step 3-
Once Jenkins server is up and running, you will get above success message.
By default Jenkins runs on 8080 port so you can navigate to below URL for Jenkins UI
Open any browser and type the URL http://localhost:8080
Now Jenkins in up and running so now we have to configure Jenkins so that we can execute our test case via Jenkins.
Step 4-
Once Jenkins is running so we are almost done but before moving to create build we need to configure Jenkins so that Jenkins can identify other tools as well like Java, Maven etc.
Click on > Manage Jenkins
Click on Configure System
Here we are telling Jenkins that our java is located at this location so we don’t have to worry about the explicit path.
Navigate to JDK section and Click on Add JDK button
Uncheck Install automatically check box so Jenkins will only take java which we have mentioned above.
Give the name as JAVA_HOME and Specify the JDK path
In Jenkins, we have a very good feature that you can configure email notification for the user.
This is optional but if you want to configure Email notification then you have to do little setting while configuring Jenkins
Refer below screenshot you can change login details and click on Apply.
Once done click on save and apply.
Congrats, your Jenkins is configured now.
Part 3- Execute Selenium build using Jenkins
We can execute test cases in Jenkins using 4 ways refer the below screenshot
In this post, we will execute using Window batch command
Step 1- Create a batch file first then we will add the same batch file to Jenkins
a-To create the batch file we need to set classpath of TestNG so that we can execute testng.xml files
our project structure should look like
b- Open command prompt and set the classpath-
While setting classpath we will 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 system
c- Open notepad and type the below command and save as .bat file –
In my case, I have saved as run.bat
java -cp bin;libs/* org.testng.TestNG testng.xml
Step 2-
Create a job in Jenkins which will execute our build
Open Jenkins on browser (type http://localhost:8080)
a- Click on the new item
b- Give the Job-Name, select Build a free-style software project and Click on OK button
c- Navigate to Advanced Project Options > Check the use custom workspace > in directory we will specify the project home directory
d- Important part now specify the Add Build step >Click on Execute Windows batch command
e-In the section please specify the batch file which we created and click on Apply and save
Step 3- you can finally run the Build > Click on Build now option
Step 4- Check Build history and Console output and verify the output
Part 4-Schedule your build in Jenkins for periodic execution
Jenkins comes with very good functionality in which we can schedule jobs which we created
You can schedule build for existing jobs which already created and while creating new project also we can specify the same.
Let’s schedule the job. Refer the below screenshot
Step 1-
Open job which we created now and Click on configure > select the check box build periodically
Step 2-
Specify the time here we need to careful about the syntax
Jenkins works on Cron pattern for more info about cron refer cron link http://en.wikipedia.org/wiki/Cron
Jenkins will accept 5 parameter lets discuss one by one
* * * * *
Here the first parameter- specify minute and range will vary from 0-59
Here the second parameter- specify hours and range will vary from 0-11
Here the third parameter- specify day and range will vary from 0-7 here 0 and 7 will be Sunday
Here the fourth parameter- specify month and range will vary from 1-12
Here the fifth parameter- specify year so here you can specify *
Example 1- if you specify 00 22 * * * it means your build will run daily @ 10 PM
Example 2- if you specify 50 * * * * it means your build will run daily 50 min after every hour
Example 3- if you specify 00 22 1 * * it means your build will run every Monday @ 10 PM
Finally, we have executed our test case successfully. If you have any issue while running Jenkins please comment below post if you are finding some issues.
Thanks for visiting my blog. Keep in touch. Have a nice day 🙂
Would love to hear from you.
RAJ says
Hi Mukesh,
How to supply jenkins parameters to selenium testscripts ? Please let me know.
Mukesh Otwani says
Hey Raj, here is the video https://youtu.be/gT9qnZi3f74?list=PL6flErFppaj0WwNOMFeXPVlNCDuJyPYFi&t=2121
Piyush says
In case of mac,i am unable to do below step
Home directory > set classpath=C:\Users\Learn-automation\bin;C:\Users\Learn-automation\libs\*;
on mac getting below error
piyush@Piyushs-MBP SeleniumProject % set classpath=/Users/piyush/IdeaProjects/SeleniumProject/bin;/Users/piyush/IdeaProjects/SeleniumProject/libs/*;
zsh: no matches found: /Users/piyush/IdeaProjects/SeleniumProject/libs/*
Do i need to manually create the libs and bin folders in my project structure?
Note:i am using maven project.
Mukesh Otwani says
Hi Piyush,
If you are creating maven project then there is no need for libs and bin folder. Until unless, you have any library which is not available in maven repository. You can refer this link for ready understandibility https://www.youtube.com/watch?v=vFXL4nMWvXI&list=PL6flErFppaj0WwNOMFeXPVlNCDuJyPYFi
Tester_br says
Hi Mukesh,
Thanks for this guide, it’s really helpful.
Could you please give more details about libs and bin folders? What do we need to add to them?
Thank you!
Mukesh Otwani says
Hi Villa,
Thanks for approaching me. bin folder contains .class files which are java executables and libs contains dependencies which are required during runtime. That is why we setting classpath of these folders. This is old approach. I would recommend you to go with maven which is easy to maintain
Venkatesh says
Hi Mukesh,
How to execute shell command used on Jenkins Slave : Chrome Browser Parameterization. If you have any idea or video link please share me.
Already code is hardcoded in shell command for my project
Mukesh Otwani says
Hi Venkatesh,
Create String/Choice Parameter in Jenkins job. Modify your shell script by which it can accept browser as parameter in runtime like ./ browser. Once it is done then you pass jenkins parameter like ./ $
Ravi says
Hi Mukesh,
My selenium test are passing locally But , some tests are failing in jenkin’s specially the one where I have used Assert class methods like assertTrue / assertFalse (i’ve used it for success message verification) .
Although, These tests are also passing locally.
I have tried few things to sort out these failure like used explicitwaits, used pagesource method to find the actual message but nothing worked.
What could be the issue. Pls let me know.
Thanks.
Ravi
Mukesh Otwani says
Hi Ravi,
Have you checked the screenshot of corresponding where your test is getting failed. This would help you to analyse issue well.
ram says
how can i do code integration, different people implemented code for selenium famework
Mukesh Otwani says
Hi Ram,
For integration of code, your team must have common code repository like SVN or Git which help all to integrate individual code efficiently without redundancy.
madhavi says
Hi mukesh,
I have configured maven project in jenkins but my scripts are running in headless browser .what changes i need to do to display the browser.please help me
Mukesh Otwani says
Hi Madhavi,
By default in Jenkins, web browser execution runs on headless mode on master. In order to see actual execution, you have to create slave and run your execution on newly created slave.
Avinash Yerramsetti says
Hi Mukesh, Can you direct me to a tutorial where it teaches Integration of Nightwatch with Jenkins. Thanks
in Advance
Mukesh Otwani says
Hi Avinash,
Apologies, I haven’t posted anything about nightwatch js framework.
Rajesh says
Hi Sir,
I learned lots of things with your vedios and it is very helpfull for my work i would like to pay thanks for this.
Now I am runing my Automation script in centos server using jenkins but I am facing one issue i.e “org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary”
Can you plz help me sir. And this problem is only coming wh=en i am running my script in centos server of my AWS instance.
Mukesh Otwani says
Hi Rajesh,
It looks like chrome browser is not installed on your Jenkins hosted server. If not installed, download chrome-stable.rpm from chrome website using wget or any other tool then install it using sudo yum install ./gogole-chorome…rpm
madhavi says
hi mukesh
in one scenario i am facing one issue in automation button is not enabling after entering the mandatory fields but when i entered manually button is enabling i don’t know i could be the reason please help out.
Mukesh Otwani says
Hi Madhavi,
Once you fill last mandatory field, call TAB key using Actions class or click on somewhere else so that validation for all filled fields gets done.
madhavi says
Thank you mukesh
Santosh says
Hi Mukesh,
Need to run my scripts in Ubuntu Platform through Jenkins
Please help me the same!
Mukesh Otwani says
Santosh,you can use Docker here to run Selenium on Linux.
Vijaya says
Hi Sir,
I have installed Jenkin on my window machine version 2.164. Login is required to use the jenkin, I have skipped the registration process, and now i dont remember the default password. How to login to the Jenkin?
Mukesh Otwani says
Hi Vijaya,
Go to .jenkins folder(generally in your user folder )-> Open Config.xml file -> Look for tag useSecurity -> Change its value from true to false -> Save that .xml file -> Restart your jenkins
Ram says
Hi,
Kindly provide your advice…we are using selenium tool with hybrid framework…How to integrate the selenium and Jenkins for dynamically select the different script sheet and test data sheet.
Ex: Using multiple scripts sheet and Test data sheets for each module.
Note: Our application size is very big 1000 screens. But continuous we are using more that 200+ screens.
Mukesh Otwani says
Hi Ram,
Create discrete test case and you can use batch/shell commands to run your different scripts wrt corresponding data sheet and obviously it will take time.
Sudeep says
Hi, My bin structure is
C:\projectWorkSpace\TMS\bin\executionEngine and inside this there are three class files
1)LoginTMS.class
2)registerTMS.class
3)TaskEntry.class
I have to run registerTMS.class
Could you let me know command which i need to include in my bat file
Mukesh Otwani says
Hi Sudeep,
You can pass only registerTMS.java in your xml and run.
Azhar says
Hi Mukesh,
Need to run jenkins job but browser should be visible,
How we can do this?
Mukesh Otwani says
Hi Azhar,
If you are using windows machine as Slave then don’t run slave as windows service.
roushini says
hi
thanks i was a ui dev like 2 weeks ago thanks to ur youtube channel and tese articles , im able to work on real project scenarios as a tester better in a matter of no time, please keep up the good work
thanks again and if possible can it be more python related (jus hoping or if u cud point me to somewer i can tose better will be grt)
Mukesh Otwani says
Hi Roushini,
I am working on python stuffs.
Mak says
Hi Mukesh,
I need to test number of similar sites with different URLs, but the sites are almost similar, and I can use same set of test cases for all the sites. I also need to test on different browsers and different environments like stage, prod etc.
Now my question is, if I want to run test suite for only 2 sites, on only one environment(e.g stage), on only two browsers (out of many, say 3), is it possible to decide this at run time?
I am asking this because, I want it to be decided dynamically, and one should not need to make changes every time in xml to decide on which site, env., browser to execute on. (e.g.: Some times, we need to test only one or two site on only one browser)
Could you please suggest if there is any way to achieve this.
Thanks.
Mukesh Otwani says
Hi Mak,
As per your requirements, you definitely need to go for testng xml file. You can provide testcase name, gruops, parameter…so on to xml file while building. For this you need to create a Java class which can parse xml file and accept theses parameters.
Sudha says
Hi Mukesh, I’ve a doubt and i know that’s silly but i want to clarify it. Whether we can integrate selenium scripts with jenkins without using testng test scripts. Apologies if this sounds stupid.
Mukesh Otwani says
Hi Sudha,
yes, you can…As per java, you need to mention main() method in the java file(the one which you want to execute). After building dependencies using POM.xml, just navigate to folder where you have kept your java file then execute as you do in cmd.
Alex says
I was wondering if someone can help me with this issue that I am facing when I click on failed test browser screenshot in jenkins to see the failed image I got 404 page not found.
I had jenkins setup in linux machine and I am using 4 vm’s grid which is work before in another machine the only thing I did I reinstall jenkins in new machine no changes has been done on the testlistener.
Hope that anyone can direct me to the right track.
Thanks
Mukesh Otwani says
Hi Alex,
As you mentioned that you have new jenkins instance. Could you please check whether the url which is being referenced to view failed screenshot is correct or not.
Gurjot Ahuja says
Awesome steps, it worked for me! One thing I would like you to edit above :
In run.bat file, the command should be :
“java -cp D:\Eclipse_workspace\Selenium_CMS\libs\*;D:\Eclipse_workspace\Selenium_CMS\bin org.testng.TestNG testng.xml
“
Mukesh Otwani says
Thanks Gurjot for updates. I will make the changes soon.
Shiva Krishna says
Hi Mukesh, Recently i have installed Jenkins in my company it was installed successfully but the problem is that when we are trying to trigger a report mail using our company mail ID. Could you please send the reply reason behind this issue.
Mukesh Otwani says
Hi Shiva,
Did you try Test Mail option inside Manage Jenkins. Moreover it depends on your network connection. Its better if you contact your organizational network admin.
Shoaib Patel says
Hi Mukesh,
If Jenkin server is hosted on a headless unix machine, this will not work. Can you please explain how to execute Cucmber Selenium java scripts on such server?
Thanks..
Mukesh Otwani says
Hi Shoaib,
This will help https://www.youtube.com/watch?v=ceRnV0C3pDw&t=4s
Amit Kumar Singh says
Started by user anonymous
Building in workspace C:\mywork\Jenkins
[Jenkins] $ cmd /c call C:\Users\AMITSI~1\AppData\Local\Temp\hudson8254443489790097217.bat
C:\mywork\Jenkins>run.bat
C:\mywork\Jenkins>java -cp bin; libs/* org.testng.TestNG testng.xml
Error: Could not find or load main class libs.*
Build step ‘Execute Windows batch command’ marked build as failure
Finished: FAILURE
Can you tell me, how to resolve this issue.
Mukesh Otwani says
Hi Amit,
Please try with maven https://www.youtube.com/watch?v=A4Z1F7gJvkY
Zafar says
Hi Mukesh,
First let me say thank you. I have learnt a lot from your tutorials.
Now regarding the “Selenium integration with jenkins”. i have followed you tutorial and steps exactly. When i use just a printout statement it works for both(eclipse and Jenkins).
When i use following code.
package demoJenkins;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class JenkinsDemo {
@Test
public void testJenkins(){
System.out.println(“Selnium has been configured with Jenkins”);
System.setProperty(“webdriver.gecko.driver”, “D:/Selenium/softwares/geckodriver.exe”);
WebDriver dr = new FirefoxDriver();
dr.get(“http://www.facebook.com”);
System.out.println(dr.getTitle());
dr.quit();
}
}
This code works for Eclipse without any error. But in Jenkin it says
“D:\java\Jenkins>java -cp bin;lib/* org.testng.TestNG testng.xml
[[TestNGClassFinder]] Unable to read methods on class demoJenkins.JenkinsDemo – unable to resolve class reference org/openqa/selenium/WebDriver”
Could you please suggest me the problem with it?
Mukesh Otwani says
Hi Zafar,
Please try with maven https://www.youtube.com/watch?v=A4Z1F7gJvkY
Note- Now a days in companies maven only used.
Ahmed Bilal says
You are the best Mukesh! good sharing … did same in same pace with your demo (y)
Mukesh Otwani says
Great Ahmed. Cheers 🙂
Saurabh Sahu says
hello,
when i open url ,getting authentication pop up so which credential i should give and i tried my window credential that is not working
Mukesh Otwani says
Hi Saurabh,
Please follow below guide http://learn-automation.com/handle-windows-authentication-using-selenium-webdriver/
Arunpandi says
You are great bro !! I have seen some of your videos also in youtube before.
I am going to try this one…Thank you again!!
Mukesh Otwani says
Yes sure try and let me know if any issue.
Ram says
Hi Sir,
I have one doubt in jenkins ..
How we will call selenium tests from jenkins
Mukesh Otwani says
Hi Ram,
Above guide covers the same only.
Patricia says
Hello Mukesh,
Quick question. I don’t have the folder lib that you mention in your screenshot.
What’s the meaning of this folder? Should I have one in my project?
I cannot implement your solution 🙁
Thanks in advance!
Mukesh Otwani says
Hi Patricia,
Lib folder we have to created manually and we need to keep all jars which we downloaded from Selenium site.
I also use maven approach to run test from Jenkins (Recommended)
Here is the link for video https://www.youtube.com/watch?v=A4Z1F7gJvkY
Manoj says
Hi Mukesh, I AM Following From Long time and It’s a Gr8 Resource For All The Testers But In The Jenkin Video Ur Using 1.6 Version But in 2.19 Jenkins Version There is no Such Options For JDK path setup. So Can U Guide Should I need to Enter the System Variable Details Or We Can Skip That
Mukesh Otwani says
HI Manoj,
You can get this option in Manage Jenkins >Global tool configuration
Arvind says
Hi Mukesh I want to attach target folder index.html in my jenkins mail. How do I achieve that? I am using junit with cucumber. In the attachment section I am passing target/cucumber-htmlreport/feature-overview.html/**
Mukesh Otwani says
Hi Aravind,
Check this link https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
shivkumar says
Hi, Mukesh.
I have installed and configured Jenkins…but didn’t create an account instead entered as an ADMIN…Later, logged out of the account…
Now, as I want to use Jenkins,it’s asking for login & password and theirs no option to create a new account ….plz guide me to create a new one.
Mukesh Otwani says
Hi Shiv,
You can delete .jenkins folder from C drive user folder and try to do it again with Jenkins 1.6 version.
shivkumar says
Thanks buddy for ur quick response…
I m referring ur blog & all the youtube selenium videos…they simply awesome…thanx (y) 🙂
Mukesh Otwani says
thank you shiv
manish says
Hello Mukesh, please help me here
1 ) in Jenkins, How can we send report of successful builds to recipients? (email)
2) How can we send automatic test report emails (in Eclipse) to recipients once our TestNG tests completes
Mukesh Otwani says
Hi Manish,
For Jenkins Email-Ext plugin can be used.
From Selenium you can use below link
http://learn-automation.com/send-report-through-email-in-selenium-webdriver/
manish says
Thanks a lot Mukesh for quick and great reply.
Your Jenkins’s short & crispy video on YouTube is superb
Mukesh Otwani says
Glad it helped 🙂 Thanks Manish
yogesh says
im using mac OSX , i want to run selenium test case in command terminal and i don’t know commands in mac pls help me example i want to excute my all test suit at one (terminal)
Mukesh Otwani says
COnfigure maven only and rest will remain same.
sindhu says
HI mukesh , im using mac OSX ,i have to execute the script in execute shell which command should be used and whats the procdure
Mukesh Otwani says
Hey Sindhu,
You can directly give path of pom.xml file in OSX then you dont have to write shell script for this.
refer below video for more details
Rohit Sharma says
How can we configure latest Jenkins 2.7.2 ??
I didn’t see any JDK installation link
Mukesh Otwani says
Hi Rohit,
You can find in Global tool configuration.
kanchana says
Hi Mukesh sir, I downloaded jenkins (1.6version) also but i cannot see any jdk installation tag on jenkins ?
please help me in this issue?
Mukesh Otwani says
is it fixed?
kanchana says
Hi mekesh sir,
while executing testng.xml through command propmpt …i am getting this error
Could not find or load main class org.testng.TestNG….
please help?????
Mukesh Otwani says
Hi Kanchana,
Kindly use maven project and run pom.xml file from cmd.
Nipun says
I tried to run my project using Jenkins.There is a functionality where I need to upload a document.
Its working fine on eclipse.But Jenkins does not allow me to upload the file.
Can you please provide me with the solution.It would be really helpful
Mukesh Otwani says
Hi Nipun,
Are you using sendKeys or AutoIT. I also have so many scenario like this but it works for me always.
Arpita says
Hey Mukesh,
I am also facing the same issue. i am using ActiveIt. Could you please help me with a way?
Mukesh Otwani says
What is ActiveIt Arpita?
Arpita says
i’m sorry i meant AutoIT.
I have prepared an .exe and using that to upload files form local.
This is working fine on my local m/c but not working with jenkins, it is not being able to identify the popup then.
Please help…
Mukesh Otwani says
Hi Arpita,
Try with Robot class. It works with Jenkins as well.
Vandana says
In short, using jenkins I am unable to launch any site in the firefox browser using command driver.get(“url”);
Mukesh Otwani says
HI Vandana,
Try below post http://learn-automation.com/use-firefox-selenium-using-geckodriver-selenium-3/
Pooja Vengurlekar says
In above tutorial, while performing above steps, at step 4, I don’t find JDK under Manage jenkins ->Configure System. Please help
Mukesh Otwani says
Hey Pooja,
Kindly download Jenkins 1.6 version then only above options will come.
praveen says
hi mukesh ..
ur youtube video is very usefull
Mukesh Otwani says
Thanks Praveen
Naveen Balanagu says
Hi Mukesh,
I have configured and everything works fine. But I would like to see the browser when I run the tests using jenkins. Can you tell me if that is possible?
Mukesh Otwani says
Yes if you install Jenkins as war file then you can see the execution live.
Naveen Balanagu says
Thanks Mukesh. I reinstalled and configured it again and this time it shows the browser running tests.
Mukesh Otwani says
Hi Naveen,
Good to hear. Cheers 🙂
Omar Careem says
How to run selenium tests using chrome driver in jenkins? Please let me know.
Mukesh Otwani says
Hi Omar,
Process will remain same only small change in script. You can use ChromeDriver()
Below url will help http://learn-automation.com/launch-chrome-browser-using-selenium-webdriver/
Roman says
Hi Mukesh , I am trying to run my selenium test with chrome browser in Jenkins . Our company Jenkins supported by AWS . I can run test with firefox but I am not able to run with chrome . I don’t want headless browser , I want run my test with chrome browser in Jenkins browser . Locally my test run with chrome browser perfect but Jenkins is not supporting .If you provide step by step it will be great. I couldn’t find any video or description online . No one talking about it . If you can give us solution it will be very helpful for everyone
Mukesh Otwani says
Hi Roman,
As per my knowledge, if your execution is running in headless mode then the slave is installed as service(in windows) on which your test is running. Connect slave without installed as service.
usama awan says
Hi Mukesh;
I am using selenium version 2.53 and firefox 45.02
On mac when i run my selenium TestNG test case from eclipse/terminal they work perfectly fine but when i build them form Jenkins they fail while locating elements.
Mukesh Otwani says
Hi Usama,
Strange for me. Can you please check the console log/error so that we can check the issue.
chandrasekhar says
superb info..thank you very much
Mukesh Otwani says
Your most welcome Mate 🙂
Manmohan says
I have successfully installed jenkin in linux sever . i want to execute my test case or testng.xml which is on local system. and sever is command based , there is no browser support . i want my test case to run in server(linux) automatically . what should i do.
Mukesh Otwani says
Hi Manmohan,
Not sure on linux 🙁
Sofia says
i got error in cmd when i gave java -jar
unspecified jar
Mukesh Otwani says
Hi Sofia, Kindly mention the jar also after java -jar jenkins.war
Prashant Soni says
thanks mukesh sir, following information are so helpful
Mukesh Otwani says
Thanks Prashant.
Anmol says
Hi Mukesh,
I am not able to run web based selenium scripts using Jenkins. For ex, I have a script which login to gmail and check my emails but not able to make it work from Jenkins.
Is there any plugin required for the same. ?
Mukesh Otwani says
Hi Anmol, Kindly provide console output with issues.
Anmol says
Hi Mukesh,
There is no error on the Jenkins side. The script passes successfully in Jenkins. But I am not getting the desired result. Let me explain more about my scenario –
My Selenium script uses excel sheet to fetch the login id and pwd and then it login to gmail and read the subject of emails and enter it in another excel. This script runs fine as standalone Java application in eclipse. But when configured with Jenkins it is not reading any email and hence not writing anything in the excel sheet. The funny things is – In Jenkins console the script passes successfully.
The example you have provided works fine in Jenkins at my end also. I can login to facebook and read the title. But my scenario of gmail is not working.
I am highly thankful that you took time to address my issue. Please see if you can provide more help. Thanks.
Mukesh Otwani says
Hi Anmol,
I just tried same thing and it worked like charm.
Test admin says
Hi, If I follow the above steps in Linux, will it work?
Mukesh Otwani says
Yes hope so
Pradeep Samson says
Hi Mukesh,
I am getting one error while adding test class – @Test
“Test cannot be resolved to type”
Please help!
Mukesh Otwani says
Can u provide the code as well?
Anwar says
Hi Mukesh,
how to schedule builds in jenkins with out periodically . it means automatically it will run continuously one by one. Please let us know
Mukesh Otwani says
Hi Anwar,
I have not tried but its good question let me check out. I use click build now option to run build in Jenkins.
pavankumar says
Hi Mukesh,
I have done the jenkins setup and i am able to run the job with maven integration. I added the recipients list in the Editable email notification section. After the completion of job, i didn’t get any mail from the jenkins. I got “No emails were triggered.” in console output. Please help me!
Mukesh Otwani says
Hi Paavan,
Is email config is correct?
pavankumar says
Hi Mukesh,
I checked the configuration and tried to trigger test mail from jenkins which is sent message successfully. I configured the email settings in both Configuration system in Manage Jenkins section, and in Postbuild step in Job configuration also.
Can i have an option to attach screenshot to this reply to explain in a better way what i have configured.
Mukesh Otwani says
Hi pavan,
This plugin will help you https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
Rupesh says
Hi Mukesh,
Very good stuff to understand the next level of selenium process.
Can you please provide the details to connect Jenkins for python
Kind regards
Mukesh Otwani says
Hi Rupesh,
I have not tried with Python but will give a try for this.
Amod Mahajan says
Hi Mukesh,
I have a maven project which runs perfectly through eclipse but when I try to run same project through jenkins, it is getting failed in @BeforeTest only.
Getting below error message:
Running TestSuite
Starting ChromeDriver 2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129) on port 40679
Only local connections are allowed.
Tests run: 3, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 63.388 sec <<< FAILURE!
beforeTest(MavenDemo.MavenEx) Time elapsed: 63.232 sec <<< FAILURE!
org.openqa.selenium.WebDriverException: unknown error: unable to discover open pages
(Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 10.0.10586 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.06 seconds
Build info: version: 'unknown', revision: '31c43c8', time: '2016-08-02 21:57:56 -0700'
System info: host: 'DESKTOP-G2E94QN', ip: '172.16.2.152', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Mukesh Otwani says
Hi Amod,
Can u try with Chrome driver 2.22
Ranjitha says
Hi Mukesh,
I am following the same steps as mentioned by you above.
I am stuck in Jenkin proxy configuration.
Without proxy configuration, email notification is not available.
But unable to configure proxy setting.
java -jar Jenkins.war works fine.
I can see it says it is up and running successfully.
Later in http://localhost:8080, Proxy configuration, gives error
Kindly, let me know how should i proceed.
Mukesh Otwani says
HI Ranjitha,
Have you tried below steps to set proxy?
Bimlesh says
Hi Mukesh,
I am trying to run my maven test from github using jenkins.
I am trying to create a new item by selecting maven project and chosing GIT from source code management. When I give the reporsitory URL as “git@github.com:Bimlesh1681/AmazonIndia.git” – I get the error ==> Failed to connect to repository : Error performing command: git.exe ls-remote -h git@github.com:Bimlesh1681/AmazonIndia.git HEAD
Also with the new version of jenkins, I do not see any options to configure JDK from jenkins > configure system.
Please advise on both these issues.
Mukesh Otwani says
Hi Bimlesh,
I shared video for github and for jenkins you can use Global tool location.
CLick on manage jenkins – Global tool location. then JDK
Bimlesh says
Hi Mukesh,
Thank you so much for sharing the videos and it was very useful.
kindly advise on these issues which is stopping me to execute my first job from jenkins 🙁
Issue 1: I am now able to configure JAVA successfully from the Global Tool Configuration section and from GIT section,
the Path to Git executable is by default set to git.exe which is giving me the error
“There’s no such executable git.exe in PATH: C:/Program Files (x86)/RSA SecurID Token Common,
C:/ProgramData/Oracle/Java/javapath, C:/windows/system32, C:/windows, C:/windows/System32/Wbem,
C:/windows/System32/WindowsPowerShell/v1.0/, C:/Program Files/ActivIdentity/ActivClient/, C:/Program Files (x86)/ActivIdentity/ActivClient/,
C:/windows/System32/WindowsPowerShell/v1.0/, C:/Program Files/Java/jdk1.8.0_71/bin/.”
Issue 2: Also when I am trying to configure a new job from jenkins by choosing Git from the Source Code Management,
I am specifying the repository URL git@github.com:Bimlesh1681/AmazonIndia.git which is giving me the error
“Failed to connect to repository : Error performing command: git.exe ls-remote -h git@github.com:Bimlesh1681/AmazonIndia.git HEAD”
Mukesh Otwani says
is it fixed? Bimlesh
Bimlesh says
Hi Mukesh,
The issue got fixed when I configured the GPG key too along with the SSH key.
(https://help.github.com/articles/telling-git-about-your-gpg-key/)
Thanks for checking! 🙂
Mukesh Otwani says
Cheers Bimlesh
Ranjana says
Hi Mukesh,
Can you please post the video for complete Maven Project Deployment using Jenkins.
Mukesh Otwani says
Hey Ranjana,
I have already uploaded on Youtube and here is the link for the same https://www.youtube.com/watch?v=A4Z1F7gJvkY
Ranjana says
Hi Mukesh,
How to run the selenium tests with “execute shell” option. Please help!
Mukesh Otwani says
Hi ranjana,
for linux also you can use maven commands.
Mohanasundaram says
pls help me,
how to resolve this issue”[TestNG][Error]
cannot instantiate class Com.Helper.Testing
Note:Com.Helper is package name
Mukesh Otwani says
You can give some other package name and will run code again.
sahil says
Hi Mukesh,
When adding jar in the jenkins getting error message “C:\Program Files\Java\jdk1.8.0_05 doesn’t look like a JDK directory”.
Thanks
Sahil
Mukesh Otwani says
Hi Sahil,
It seems JDK in installed at some other location. Kindly check the location again.
kiran says
Hi Mukesh
Thanks for the wonderful tutorial.You made it look very simple.
I’ve configured my project to run the Build with Jenkins if I execute the testng.xml on my own it successfully execute my test case but if I execute via cmd it simply skips the test and also in Jenkins I get the following error message
===============================================
Suite
Total tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
Build step ‘Execute Windows batch command’ marked build as failure
Finished: FAILURE
However it execute the build successfully if test case output is just using `(system.out.println();)
if test case relates to opening of browsers it gets failed via Jenkins
I used the java -cp bin;lib/* org.testng.TestNG testng.xml command as well doesnt work neither in cmd nor in jenkins.
My jdk bath in configuration I double checked its right.
C:\Program Files\Java\jdk1.8.0_92
Thanks in advance!
Mukesh Otwani says
Hey Kiran,
If you are using Maven they try to run pom.xml file from Jenkins.
Yuva says
Hi Mukesh,
I have a dought, I design a frame work with Extend Report’s every thing is fine. But if we integrate with Jenkins it’s not working. With out ExtendReports it’s working.
Can you please let me know any Plugin is available for ExtendReports? , if it is please specify the name.
Mukesh Otwani says
Hi Yuva,
No plugin for jenkins for extent reports.
Jai Prakash Keswani says
Hi Mukesh,
When I type “http://localhost:8080” in FF. I receive an error
“Unable to Connect”
“Firefox can’t establish a connection to the server at localhost:8080.”
Mukesh Otwani says
It means jenkins is not started
Jai Prakash Keswani says
Hi Mukesh,
Thanks very much for the easy step by step tutorial. but while setting classpath I am gettig following Error.
C:\Users\SDWA-174\workspace\Guru99>set classpath-C:\Users\SDWA-174\workspace\Guru99\bin;
Environment variable classpath–C:\Users\SDWA-174\workspace\Guru99\bin; not defined
C:\Users\SDWA-174\workspace\Guru99>set classpath-C:\Users\SDWA-174\workspace\Guru99\lib\*;
Environment variable classpath–C:\Users\SDWA-174\workspace\Guru99\lib\*; not defined
Could you please clarify, why do we get this kind of error.
Mukesh Otwani says
Some space issue kindly follow video again.
upali says
Hi Mukesh,
Can you show how to add a build step using Maven?
Mukesh Otwani says
Hey Upali,
Here we go http://learn-automation.com/selenium-maven-build-and-usage/
Neha says
Can u clarify what does lib and bin consists of ?? Please note i donot have such folders as I am using a maven project(with pom.xml)..I want to run Testng.xml from jenkins ..How do I do that ??Your quick reply will be appreciated.
Mukesh Otwani says
Hey Neha,
Lib contains all jars.
Bin contain binary files, you will get this folder if you are working with plain java project. If you are working with maven then you can provide testng.xml in pom directly.
Tejas says
When i have clicked on build now in jenkins, system is opening the browser and run the script on browser UI.
Mukesh Otwani says
Hey Tejas,
It working I guess so what is the issue here?
Adeel Zahir says
Hi Mukesh
I am getting this error
Error: Could not find or load main class org.testng.TestNG
Did I miss any step of including testng?
Mukesh Otwani says
Hi Adeel,
Class path is not set properly please set class path again.
Adeel Zahir says
Thank you. It worked.
Mukesh Otwani says
Cheers 🙂
Adeel Zahir says
I am able to run testng.xml from eclipse. But when I run it from terminal, it gives an error
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
I have tried almost all the versions of selenium but its not working.
Firefox version: 31
Mukesh Otwani says
Hi Adeel,
Please use FF 45 and Selenium 2.53 version to fix this error.
Ayushi Sharma says
I could not find videos for Create build and Execute build for nightly execution and Emailable functionality ,
could you please ping link here ?
Mukesh Otwani says
Ankita Jangra says
Hey Mukesh,
I want to do Cucumber-jvm reportin ng using Jenkins plugin (Cucumber-jvm report) and facing the error something like .json file is not found in the expected folder. However, this .json file is created under Eclipse. But, not in the workspace.
Please help me out!!!
Thanks in Advance 🙂
pankaj says
i have face a problem during integrating jenkins when after typing in cmd java – jars jenkins.war
it show error:Could not create the Java Virtual Machine.
A fatal exception is occurred .The Prg is Exit. What can i do pls help me.
Mukesh Otwani says
Hi Pankaj,
Please check java properly installed and Java path is set properly
Shri says
Hi Mukesh – Thanks for such a easy to follow tutorial on Jenkins – Selenium Integration. Originally my HF reads which browser to execute from excel. But in Jenkins it started throwing error. So I created three different java classes under the package J_Demo(copied code from HF) gave name as J_chrome, J_ff and J_IE. Basically it will read data from excel as browsers are defined with in these java classes. Converted to Testng test. Created batch file separately, but when I executed them from cmd both Firefox and IE threw error. No issue in chrome, successful test run in Jenkins too. Not sure what is the error in FF and IE. Can you please help? Thanks!
Carl Jerich Lague says
Hi Mukesh!
Your tutorial is wonderful! However may I ask if Jenkins with selenium integration can be possible with an application ran by C Sharp? I’ve been searching for helpful tutorial but so far this is the most relevant tutorial I have found. Thanks!
Mukesh Otwani says
Hey Carl Thanks 🙂 Yes we can easily integrate any C# application with Jenkins. You can trigger batch command or shell script etc from Jenkins.
Carl Jerich Lague says
I am trying to trigger c sharp application from selenium then to Jenkins. Is that doable? thanks!
Mukesh otwani says
Can you tell me what exactly you want to trigger ? is it a script?
Kabirul Islam says
Nice! Keep it up.
Mukesh otwani says
Hey Kabirul thanks keep visiting.
reddie2203 says
Hi mukesh,
Can you refer me or share me any document on executing selenium webdriver maven scripts on Remote machine (without TestNG) from Jenkins CI tool .
Mukesh Otwani says
HI Reddie,
Why you are not using TestNG? Is there any condition?
Satya says
Hi Mukesh..
Please share a post regarding how to configure selenium builder file in jenkins and how to execute build remotely.
Mukesh Otwani says
Hi Satya,
I guess Selenium builder is deprecated.
Ajit Singh says
Hi,
“Here second parameter- specify hours and range will vary from 0-11”
Range should be from 00-23 not till 11.
Mukesh Otwani says
Hi Ajit,
Thanks I will update the post.
Srikanth says
Hi Mukesh,
Am facing issue while uploading file in jenkins.Its working normally when i execute on eclipse.But same when i execute
on jenkins,its not happening.
Pls help
Mukesh Otwani says
Hi Srikanth,
Are you using Robot class or AutoIt. I use AutoIT and it works normally without any issue.
Sanjay Mohan says
Hi Mukesh,
I have downloaded the Jenkins war file but while I try installing the file in Cmd prompt I was getting the following error message – ‘java’ is not recognized as an internal or external command,operable program or batch file.
I tried following three options but nothing worked fine.Please take a look and reply.
C:UsersOM>java -jar C:UsersOMworkspaceJava_trainingjenkins.war
‘java’ is not recognized as an internal or external command,operable program or batch file.
C:UsersOM>java -jar jenkins.war
‘java’ is not recognized as an internal or external command,operable program or batch file.
C:UsersOM>Java_training -jar jenkins.war
‘java’ is not recognized as an internal or external command,operable program or batch file.
Mukesh Otwani says
Hi Sanjay,
It is not jenkins issue its pure java isssue. Java path is not set properly please check and let me know
suresh says
Hi Mukesh,
i configured Jenkins (i used tomcat for jenkins) with selenium script on my windows 10 system, but sometimes it doesn’t run my test suite properly {it runs in background}. But if i run jenkins on different port by using java -jar jenkins.war then it opens browser and runs whole suite perfectly.
So what can be the problem with the jenkin with tomcat, it may not open the full screen of browser and not able to identify some elements,is it so? Please guide!!
Thanks in advance!!
Mukesh Otwani says
Hi Suresh,
In your case script running in headless mode so you are not able to see the execution which creates some sync issues.
Abhi says
Hi Mukesh,
How would you run your tests in browser and not in the background through Jenkins?
Mukesh Otwani says
Hi Abhi,
using Slave machine.
SHEKHAR says
Hi Mukesh,
Thanks for the article. Very helpful.
I have a requirement, where, after the code is built and deployed (in DEV environment) we need to execute the test cases automatically (testNG.xml). Can you please assist as to how we can do that via Jenkins ? We are through until deployment and would like to know how to run the test cases after that.
Thanks !
Mukesh Otwani says
Hi Shekhar,
is this fixed? Sorry for late reply.
shruthi says
Hi,thank you for your reply. fresh new account means ?which account I have to enter their.please tell me what account details I have to pass.IAm new to this feature implementation
Mukesh Otwani says
Hi shruthi,
Fresh account means new gmail account with less security. Just pass uname and password for authentication.
shruthi says
sending emails part is not working.
I im doing Test configuration by sending test e-mail,iam getting error like Failed to send out e-mail
javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 https://support.google.com/mail/answer/14257 xi8sm166529246pab.9 – gsmtp
Please help me
Mukesh Otwani says
Hi Shruthi,
Try with fresh new account it will work for sure. I just tried and its working fine.
Mubbashir says
I’ve configured my project to run the Build with Jenkins if I execute the testng.xml on my own it successfully execute my test case but if I execute via Jenkins I get the following error message
Build step ‘Execute Windows batch command’ marked build as failure Finished: FAILURE
However it execute the build successfully if test case output is just using `(system.out.println();)
if test case relates to opening of browsers it gets failed via Jenkins
Mukesh Otwani says
Hi Mubbashir,
It is java path issue only so try to set the path correctly then it will work I will suggest go with maven project then you wont get this issue.
Try below code
java -cp bin;libs/* org.testng.TestNG testng.xml
alvin says
Thanks for the solution Mukesh. It worked
Just want to get more info for the below scenario.
In my project am using Page Object Model with maven. I have a suite file to run BVT scripts with some 10 test script class files mapped in the suite file. Here i would like to know, how i can split to run 5 class files in Master and remaining set in slave system.
Mukesh Otwani says
Hi Alvin,
Glad to know that it worked for you :).
You can configure slave machine and you can create a parameter while will accept machine name as an argument while building project.
Based on your parameter it will trigger the script in specific machine.
Please find below link which will help you to setup Master Slave configuration.
http://learnseleniumtesting.com/jenkins-and-continuous-test-execution/
alvin says
Hi Mukesh,
I would like to know how we can distribute jobs in master and slave systems. So far i have configured my project to run in master and added a slave system to the build, but the scripts are running only in one system
Mukesh Otwani says
Hi Alvin,
Click on Job > Select checkbox “Select Label where you want to run” > Specify the node name then save.
Try this and let me know if still facing any issue.
Ed Nonog says
Hi Mukesh,
I have already configured my Selenium Script from eclipse base from your tutorial including build.xml, pom.xml etc. and I’ve already integrate the selenium script to maven , the tricky part on my instance is on how to import/hook the script into jenkins job or configure?, base from your tutorial you are using windows but my instance is Ubuntu as Jenkins server and svn as my SCM.
Thanks
Mukesh Otwani says
Hi Ed Nonog,
I have not worked on Linux so no idea on this. I have configured on windows only.
sree says
Hi Mukesh,
I have one doubt regarding Jenkins Job configuration
I have configured a Jenkins job to trigger an automated selenium script which is committed in bitbucket & used selenium grid method to run the process in a particular ip.
For the first time, the build got success. After that for the all consecutive build showing success only. But the script is not running.
Can you please suggest any option for how to diagnose or how to make the job success for all builds?
Thanks in advance,
Sree
Mukesh Otwani says
Hi SreeVidhya,
Can you please check whether it is running correct testng.xml and classes?
If possible provide me the console log to check the exact issue.
saikiran says
i am getting the error when i drag and drop jenkins.war file beside java -jar in cmd plz help me in this
Mukesh Otwani says
What error you are getting..?
Bhushan says
Hi Mukesh.. First of all thanks for the useful tutorial, I am trying out the Jekins with selenium but I want to use the build.xml file in order to execute the test cases instead of .bat file , for this I have to invoke the ant, I have done the initial set up, could you please guide me how to do using build.xml, do I need to create the slave in my case, my selenium setup and jenkins are installed in the local window machine..
Thanks,
Bhushan Patil
Mukesh Otwani says
Hi Bhushan,
I would suggest you switch from ANT to Maven and follow below steps
and if you are new to Maven then use below link https://www.youtube.com/watch?v=nasdb9QhFqg
But if you are still want to work with ANT http://seleniumeasy.com/ant-tutorials/how-to-run-testng-tests-using-build-xml-file
Bhushan says
Hi Mukesh.. First of all thanks for the useful tutorial, I am running selenium test set up which is running in my local window machine and recently I have installed the Jenkins on my local machine but I have to execute the seleninum test cases using Invoking Ant i.e. basically using running build.xml file, can u please guide me how to do this ?? Do I need to create Slave for this to run the selenium test cases ?
suresh says
Hi Mukesh ,
1)How to Selected Testcases Executing in Jenkins?
2)How to Failed Testcases Executing In Jenkins?
Please help .
Mukesh Otwani says
Hi Suresh,
Please find my comment below
1)How to Selected Testcases Executing in Jenkins?
Answer- You can create testng.xml for specific test case and mention this xml in batch file.
2)How to Failed Testcases Executing In Jenkins?
Ans- Recently I posted an article on this. Please visit this and implement in your project
http://learn-automation.com/re-run-selenium-failed-test-cases/
Hope this will help you.
Thanks
Mukesh
CGupta says
Hi Mukesh,
Can you please explain the same for c#, .Net environment ? We have post on the same over the internet but they are less informative.
Mukesh Otwani says
Hi Gupta Ji,
I have not worked on C# so really not sure.
Thanks
Mukesh
rachana says
Hi,
I am getting the following error when I run selenium batch script from Jenkins. Can anyone help me.
Building on master in workspace /var/lib/jenkins/workspace/Selenium
[Selenium] $ /bin/sh -xe /tmp/hudson636620915094945010.sh
+ /usr/bin/winexe -U mysimst/username%password //172.20.68.50 ‘cmd.exe /k cd /d D:\DevOps_Automation & poc_automation.bat & exit’
Unknown parameter encountered: “max log size”
Ignoring unknown parameter “max log size”
Unknown parameter encountered: “passdb backend”
Ignoring unknown parameter “passdb backend”
Unknown parameter encountered: “load printers”
Ignoring unknown parameter “load printers”
Unknown parameter encountered: “cups options”
Ignoring unknown parameter “cups options”
Unknown parameter encountered: “writable”
Ignoring unknown parameter “writable”
Unknown parameter encountered: “guest ok”
Ignoring unknown parameter “guest ok”
Unknown parameter encountered: “writable”
Ignoring unknown parameter “writable”
D:\DevOps_Automation>set projectpath=”D:\DevOps_Automation\AFramework”
D:\DevOps_Automation>cd “D:\DevOps_Automation\AFramework”
D:\DevOps_Automation\AFramework>set classpath=”D:\seleniumjar\testng-sources.jar;D:\seleniumjar\selenium-server-standalone-2.44.0.jar;D:\seleniumjar\selenium-java-2.44.0\selenium-2.44.0\selenium-java-2.44.0.jar;D:\seleniumjar\selenium-java-2.44.0\selenium-2.44.0\selenium-java-2.44.0-srcs.jar;C:\TestNG\guice-3.0.jar;C:\TestNG\reportng-1.1.4.jar;C:\TestNG\testng-6.8.21.jar;C:\TestNG\testng-6.8.21-javadoc.jar;C:\TestNG\testng-6.8.21-sources.jar;C:\TestNG\velocity-dep-1.4.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\poi-3.12-20150511.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\poi-examples-3.12-20150511.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\poi-excelant-3.12-20150511.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\poi-ooxml-3.12-20150511.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\poi-ooxml-schemas-3.12-20150511.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\poi-scratchpad-3.12-20150511.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\lib\commons-codec-1.9.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\lib\commons-logging-1.1.3.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\lib\junit-4.12.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\lib\log4j-1.2.17.jar;D:\seleniumjar\poi-bin-3.12-20150511\poi-3.12\ooxml-lib\xmlbeans-2.6.0.jar;D:\DevOps_Automation\AFramework\bin”
D:\DevOps_Automation\AFramework>java org.testng.TestNG “D:\DevOps_Automation\AFramework”\testng.xml
[TestNG] Running:
D:\DevOps_Automation\AFramework\testng.xml
Started InternetExplorerDriver server (32-bit)
2.27.0.0
Listening on port 18880
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
===============================================
example suite 1
Total tests run: 8, Failures: 0, Skips: 8
Configuration Failures: 1, Skips: 9
===============================================
Build step ‘Execute shell’ marked build as failure
Finished: FAILURE
Mukesh Otwani says
Hi rachana,
COnfiguration is fine I checked your log and found that you are running very old IE driver 2.27 but latest is 2.48.0..
I will highly recommend that please update all jars and IE driver and run it again.
http://learn-automation.com/download-selenium-webdriver-new-version/
Rachana says
Hi,
I updated ie driver but still getting same error.
Mukesh Otwani says
Hi Rachana,
We can have quick session and we can fix this. Add me on Skype will login and fix it soon.
Skype- sameer5085
Sagar says
Called Function : [logoutToApplication] with parameters [userName],[password]=>todakar.sagar@gmail.com,Zenith123
Called Function : [findElement] with parameters [elementLocator]=>By.xpath: .//*[@id=’wrapper’]/nav[1]/div[2]/a
Called Function : [fluentWait] with parameters [locator]=>By.xpath: .//*[@id=’wrapper’]/nav[1]/div[2]/a
Called Function : [isElementVisible] with parameters [locator]=>By.xpath: .//*[@id=’wrapper’]/nav[1]/div[2]/a
Element has been Found
===============================================
Suite
Total tests run: 32, Failures: 4, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
Build step ‘Execute Windows batch command’ marked build as failure
Finished: FAILURE
please give me solution for above error……………
Mukesh Otwani says
its all because of Sync issue.. Try tom use some wait here.. Explicit wait or Fluient wait
Mig says
has anyone seen this error and how to fix it:?
Thanks in Advance
Error: Could not find or load main class org.testng.TestNG
Build step ‘Execute Windows batch command’ marked build as failure
Finished: FAILURE
Mukesh Otwani says
Hi Mig,
There is some TestNG classpath issue. Please make sure that in testng.xml you have given classname with package.
Prashant says
I am trying to run tests from Jenkins on my local but it just does not show browser running. I am able to trigger same testng test via OSX terminal (my local). Not sure what is different while trying to run the same testng.xml file from jenkins.
Error message –
[TestNG] Running:
/Users/Shared/Jenkins/Home/workspace/TestJenkins/testng1.xml
Execute initialize function
Execute reportSetup
the main directory you are searching does exist : true
Execute test case SearchMisftToyz
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
Signing in to application
Verifying if Homepage is open
Selecting Status
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 10.05 seconds
Build info: version: ‘2.47.1’, revision: ‘411b314’, time: ‘2015-07-30 03:03:16’
System info: host: ‘Prashants-MacBook-Pro-2.local’, ip: ‘169.254.116.237’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.10.5’, java.version: ‘1.8.0_60’
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=40.0.3, platform=MAC, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 96c33170-a15e-4140-88d0-308ba32e9960
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:273)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at com.selenium.page.RentalLogHomePage.filterByStatusAndTeam(RentalLogHomePage.java:173)
at com.selenium.tests.RentalLogTests.SearchMisftToyz(RentalLogTests.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.TestNG.privateMain(TestNG.java:1364)
at org.testng.TestNG.main(TestNG.java:1333)
Caused by: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Build info: version: ‘2.47.1’, revision: ‘411b314’, time: ‘2015-07-30 03:03:16’
System info: host: ‘Prashants-MacBook-Pro-2.local’, ip: ‘169.254.116.237’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.10.5’, java.version: ‘1.8.0_60’
Driver info: driver.version: unknown
at .fxdriver.preconditions.visible(file:///var/folders/7t/bnx7__gx159fm92d4_kbnpx800007q/T/anonymous2659449284267887507webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:9982)
at .DelayedCommand.prototype.checkPreconditions_(file:///var/folders/7t/bnx7__gx159fm92d4_kbnpx800007q/T/anonymous2659449284267887507webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12626)
at .DelayedCommand.prototype.executeInternal_/h(file:///var/folders/7t/bnx7__gx159fm92d4_kbnpx800007q/T/anonymous2659449284267887507webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12643)
at .fxdriver.Timer.prototype.setTimeout/<.notify(file:///var/folders/7t/bnx7__gx159fm92d4_kbnpx800007q/T/anonymous2659449284267887507webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:623)
java.lang.Exception: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 10.05 seconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'Prashants-MacBook-Pro-2.local', ip: '169.254.116.237', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=40.0.3, platform=MAC, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 96c33170-a15e-4140-88d0-308ba32e9960
at com.selenium.page.RentalLogHomePage.filterByStatusAndTeam(RentalLogHomePage.java:492)
at com.selenium.tests.RentalLogTests.SearchMisftToyz(RentalLogTests.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.TestNG.privateMain(TestNG.java:1364)
at org.testng.TestNG.main(TestNG.java:1333)
Caused by: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 10.05 seconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'Prashants-MacBook-Pro-2.local', ip: '169.254.116.237', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=40.0.3, platform=MAC, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 96c33170-a15e-4140-88d0-308ba32e9960
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:273)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at com.selenium.page.RentalLogHomePage.filterByStatusAndTeam(RentalLogHomePage.java:173)
… 24 more
Caused by: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'Prashants-MacBook-Pro-2.local', ip: '169.254.116.237', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_60'
Driver info: driver.version: unknown
at .fxdriver.preconditions.visible(file:///var/folders/7t/bnx7__gx159fm92d4_kbnpx800007q/T/anonymous2659449284267887507webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:9982)
at .DelayedCommand.prototype.checkPreconditions_(file:///var/folders/7t/bnx7__gx159fm92d4_kbnpx800007q/T/anonymous2659449284267887507webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12626)
at .DelayedCommand.prototype.executeInternal_/h(file:///var/folders/7t/bnx7__gx159fm92d4_kbnpx800007q/T/anonymous2659449284267887507webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12643)
at .fxdriver.Timer.prototype.setTimeout/<.notify(file:///var/folders/7t/bnx7__gx159fm92d4_kbnpx800007q/T/anonymous2659449284267887507webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:623)
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 10.05 seconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 03:03:16'
System info: host: 'Prashants-MacBook-Pro-2.local', ip: '169.254.116.237', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=40.0.3, platform=MAC, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 96c33170-a15e-4140-88d0-308ba32e9960
Terminating Browser
===============================================
Suite1
Total tests run: 1, Failures: 1, Skips: 0
===============================================
Mukesh Otwani says
HI Prashant,
I can see that you are able to execute test. As per error log I found that below article will help you.
http://learn-automation.com/solve-elementnotvisibleexception-in-selenium-webdriver/
Please try and let me know if any other help required.
Thanks 🙂
Karthik says
Hi Mukesh,
Thanks for the wonderful demo…
I have run the scripts using bat file and it works perfectly…
How to run the jenkins job using Shell script…?
Mukesh Otwani says
Hi Karthik,
I have not tried with shell script so no idea. Sorry.
I will check and let u know if any useful link or video.
Karthik says
Hi Mukesh,
Thanks for the reply…
One more question..?
I have written automation script using windows operating system and than I uploaded same set of files to linux server. In windows jenkins works perfectly and not in linux.? If we need to set separate classpath in linux?
nitin82 says
Hi Mukesh, all the steps are beautifully described.
Thank you very much for helping out others.
Am getting stuck in command prompt, receiving error on executing C:UsersNitin_2\JenkinsDemo>java org.testng.TestNG testng.xml that says
[TestNG] [ERROR]
Cannot find class in classpath: demoJenkins.DemoJenkinsJobs.
Am not sure what could go wrong while performing all the steps as mentioned in the video.
Kindly revert back with a possible solution.
Thank you!
Mukesh otwani says
check this path again C:UsersNitin_2\JenkinsDemo
seems very small issue while giving class name
Please make sure before running classpath is set
nitin82 says
It was trivial! Sorry to bug you. 🙂
I was able to execute it successfully!
Will be going through other videos of yours.
Thank you very much.
Mukesh otwani says
Cheers Nitin
Karl El says
Hey Nitin, how did you resolve this ?
Mukesh Otwani says
Hey Karl,
is ur issue fixed?
Ravi Kanth says
i have run the scripts on my laptop i have create batfile but not working just open and close the window not running in cmd plz give me solution
Mukesh otwani says
What is the build status is it pass or fail?
have u referred my youtube video for the same please have a look and try the same
https://youtu.be/1e8I3A49ERc
Ravi Kanth says
hi mukesh
i have one doubt. how to install jenkins
mike comtrox says
Hi Mukesh,
there is one more query to bug you .If we have to run the script on any remote machine than where we will give the machine details(Computer name, username/password) as input. actually what will be the exact way to do this.
Thanks.
Manne Rakesh says
Nice information Mukesh Thanks
Mukesh Otwani says
Hi Rakesh,
Thanks Keep Visiting and Sharing 🙂
mike comtrox says
if I am placing my project to any remote repository . how will I give jar file mapping as in Local system we can associate/map jar files from eclipse using java Build path option
Mukesh Otwani says
Hi Mike,
Really nice question, let me explain you in detail. In your case you have to use Maven project and then you have to configure Maven in Jenkins as well. After config setting create a goal in pom.xml and run Jenkins job based on this pom.xml. This will download all jars from server itself before running your build.
Hope its clear. Soon I will share an article on this itself.
In mean while you can check below article on Maven
http://learn-automation.com/integration-of-selenium-with-maven-and-create-build-for-continuous-integration/
mike comtrox says
Hi Mukesh,
Thanks for your response , is there any other way to do this apart from using Maven project . Like giving this mapping during runtime with the help of classpath .
Mukesh Otwani says
Hi Mike,
for run time configuration I am not sure because I have not done so far.I will check and will update you
Rajasekhar Jangala says
very helpful thanks a lot
Mukesh Otwani says
Thanks Raja.. Keep Visiting 🙂
amitaks says
Good stuff !!
Mukesh Otwani says
Thanks 🙂