In previous tutorials we have seen executing testng.xml from batch file (.bat) which is an unformatted text file that consists of a series of commands to be executed by the command line interpreter. And we have also seen and executing testng.xml tests from command line,
Before proceeding, create any sample testNGProject, we have already created sample project here and we will execute the same tests here with jenkins help. After creating the sample project, project structure should look like below :
Now here we will see how to invoke batch file with Jenkins. Let us follow below steps to invoke .bat file from jenkins :
Step 1:
In Jenkins, you have an option to create 'New Job' Item, Click on it.
Step 2: -
Enter Job name and select "Free-Style Software Project" and then click on 'OK' button.
Step 3: -
You should see header as 'Advanced Project Options' and with a button 'Advanced'. Now Click on "Advanced" option which will display multiple options.
Step 4: -
Select 'Use custom workspace' and specify your project location (workspace directory) in Directory
Step 5: -
Scroll down to see 'Build' option with 'Add Build Step'. In this drop down select value 'Execute Windows batch command' which Runs a Windows batch script for building the project. The text that we enter in the text box will be executed as a batch file. The script will run with the workspace as the current directory which we have specified in step 4.
Step 6: -
Click on Save button. New Job will be created with the configure options that we have defined.
That's It. We have Done.
Now we can execute job file by clicking on the 'Build Now' button which will invoke testng.xml from the batch file. Here the output looks after executing the job:
Comments
how to create bat file ??
how to create bat file ??
Save the file with extension
Save the file with extension as '.bat' Ex: filename.bat
Here it is explained. You can check this.
https://www.seleniumeasy.com/testng-tutorials/how-to-run-testng-xml-via-...
suite not executing
Hi,
i followed the above steps which you said to execute testng for selenium through by batch file but im getting the following error which is presented below, Please help me in resolving this issue
Starting ChromeDriver 2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf) on port 23805
Only local connections are allowed.
Sep 11, 2016 2:08:49 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
This is nothing related with
This is nothing related with jenkins and TestNg.
Issue is related to selenium
jenkins error .bat
What should I do to avoid this error?
C:\Users\Kuba\git2\NameOfProject>testNGBatchFile.bat
C:\Users\Kuba\git2\NameOfProject>set projectLocation=C:\Users\Kuba\git2\NameOfProject
C:\Users\Kuba\git2\NameOfProject>cd C:\Users\Kuba\git2\NameOfProject
C:\Users\Kuba\git2\NameOfProject>set classpath=C:\Users\Kuba\git2\NameOfProject\bin;C:\Users\Kuba\git2\NameOfProject\lib\*
C:\Users\Kuba\git2\NameOfProject>java org.testng.TestNG C:\Users\Kuba\git2\NameOfProject\testng.xml
Error: Could not find or load main class org.testng.TestNG
Add all testng jars file in
Add all testng jars file in your lib folder of your project which are present at eclipse\plugins\org.testng.eclipse_6.11.0.201703011520\lib folder of your eclipse.
If still not working then add all the jar of selenium which you downloaded
problem with firefox execution
I create TestNG suite and bat file and write some basic code of open browser.
When I user Chrome it will run and execute successfully but with Firefox it shows error in Jenkins.
I try to run .xml file in eclipse manually it works fine but that same file is not working with Jenkins.
Please suggest me solution,
Thank you
Executing regression suites on different QA environments
Suppose there are 2 property files :qa1.properties,qa2.properties .
qa1.properties has properties :
URL:qa1.test.com
username:user1
password:pass1
qa2.properties has properties :
URL:qa2.test.com
username:user2
password:pass2
I have a regression suite consisting of 500 test cases .I want to run the regression suite on two qa environments(qa1,qa2) using ANT ,Jenkins.How do i accomplish it?Please suggest.
MAC
Can you please help me on accomplishing this on Mac?
Facing error in cmd Prompt while try to run the testng.xml
Facing error as java is not recognized as an internal or external command in cmd Prompt while try to run the testng.xml. I am set the enviroment variables in the properly. I am getting the version of java in my command prompt.while try to execute the below code, am facing the above mentioned error.can u pls help me to resolve this..?
org.testng.TestNG testng.xml
Add new comment