I need to run my tests in parallel but , tried to parallelize them and unfortunately it doesn't look very stable!
My new idea is to run different .xml ( one for each browser) but i need to do that in parallel
is there any way to make this stuff?
Right now i start my session by using ant
You could try with:
java org.testng.TestNG -suitethreadpoolsize 3 testng1.xml testng2.xml testng3.xml
Depending on your suite, you could also add the parallel parameter:
<suite name="My suite" parallel="tests" thread-count="5">
Check more info here.
Related
Parallel Browser Execution Possible in Cucumber (Java / Maven)?
For example I know its definately possible using TestNG when Cucumber is not involved, but is it even possible embedding Java, Cucumber, jUnit and TestNG together?
I have tried the following TestNG.xml file which points a runner class which then point to multiple feature files but have had no success :/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Automation_Scripts" verbose="2" parallel="classes" thread-count="2">
<listeners>
<listener class-name="Framework.utilities.RetryListner"></listener>
</listeners>
<test name="Automation Tests">
<packages>
<package name="TestFramework.ncc.*"></package>
</packages>
</test>
</suite>
There are no built in capabilities in cucumber for this as far as I know, but I have seen an approach where different sets of Cucumber scenarios are run by different junit classes which are then run in parallel.
Defining which scenarios are run by which class can be achieved by using either tags or defining different features for he different runner classes.
There is a maven plugin that seems to automate that approach: https://github.com/temyers/cucumber-jvm-parallel-plugin
This can be done using TestNG using cucumber.
For achieving this, you have to have independent test runners for each feature file.
eg:
TestRunnerA points to feature A in some folder
TestRunnerB points to feature B in some folder or the same
Specify the exact file in features (in cucumber options) if all features are in same folder.
And then you can specify them as separate testsin testNG xml and they will run parallely.
A sample of it can be seen here
Link
Jithu Paul answer is how this is typically approached, and this is mainly because each runner class needs to have slightly unique cucumber options for outputting test results (i.e. unique JSON file names). This roundabout way is due to not being able to parameterise Java annotations. However you can rename cucumber options dynamically using java reflection.
This project has a good example:
https://github.com/workpeter/ARGOS
In particular the runner class. As of today its located here:
https://github.com/workpeter/ARGOS/blob/master/src/test/java/integrationTests/cucumber/Runner.java
I have selenium test script written on one of my local machine and it works fine on it using testng.xml
I have copied the same script to different local machine and am trying to execute it using testng.xml by right clicking on testng.xml and selecting run as testng suite but nothing happens.
No error is shown neither script is executed or browser is instantiated.
There is no error in the project. I have added all the requred jar files.
Can any one help me with any pointer.
<?xml version="1.0" encoding="UTF-8"?>
<suite name="XXXXX">
<test name="testScripts">
<parameter name="superAdmin" value="superAdmin"/>
<parameter name="participant" value="participant"/>
<classes>
<class name="testScripts.ParticipantSide" />
</classes>
</test>
Running testng.xml from run as > configuration and specifying the suite, runs the scripts
It is running by manually specifying the suite to execute. It is still not running directly via path right click on testng.xml > Run As > TestNg Suite
Try to add the full path of your class as local machine is different. Try to build and compile or clean the entire source code and try again. Because testNG.xml seems to be the correct one.
Facing this very similar issue after I updated TestNG yesterday. In my case, I haven't copied Selenium Suite from anywhere, it was built from scratch on the very same machine that I am using at the moment.
But after I updated TestNG yesterday, I now have to go through Run > Run Configuration > path\to\testng.xml (in Suite field) and then Run it.
It doesn't work if I simply right click on testng.xml and do Run As > TestNG Suite
This question already has answers here:
Can TestNG run multiple suites?
(5 answers)
Closed 5 years ago.
I have several TestNG suite files across my multi-module java project, it's structure looks like this:
project\
module1\src\test\resources\
suite1.xml
suite2.xml
module2\src\test\resources\
suite3.xml
Is it possible to create run configuration including all these suites in IntelliJ IDEA?
I am able to create separate configuration for each of them via Run/Debug Configurations - TestNG - Configuration - Suite, but I don't see a way to select multiple files there.
I cannot merge all test suites into single suite because some tests use Before/After Suite methods.
I am using IntelliJ IDEA 14.1.2 Community edition, TestNG 6.1.1.
TestNG per se supports the execution of multiple suite files - you can run java org.testng.TestNG suite1.xml suite2.xml suite3.xml
I haven't found a way to specify multiple suite.xmls in IntelliJ, so I created a master suite using the undocumented suite-files tag. It looks like this:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1" verbose="1" >
<suite-files>
<suite-file path="suite1.xml"/>
<suite-file path="suite2.xml"/>
</suite-files>
</suite>
This suite file is runnable by IntelliJ and should include all tests, with their correct before/after methods.
So I'm trying to create a java program that uses Selenium to automate a WebDriver to perform tasks on a website. At the moment, I'm using it for work in order to automate an annoying task where the user has to upload files to our database. I've already successfully made a program which automates this, and saved myself hours of manual work.
Now I'm trying to get the program to run multiple browsers in parallel. I want to do this in order to speed up the rate at which I can upload files because most of the time is lost waiting for pages to load.
I've tested this with a much simpler version of my program and have managed to speed up simple tasks by 2-10 times by having tens to hundreds of threads open with their own WebDrivers.
The problem is, whenever I run more than 1 WebDriver the entire thing begins to randomly freak out at times, and at other times not work at all. I tried to use 'PhantomJSDriver' along with the latest 'PhantomJS.exe', however at times it would work, and most of the times it would do nothing. The same program that runs flawlessly with one driver running breaks down when they are ran in parallel.
I've been trying to find reasons as to why this happens and ways around it, but I haven't found anything definite that I can use.
How can I go about automating web browsing in parallel with Selenium if possible, and if not, where should I look to in order to do this?
This is what you need, it is called "Selenium Grid"
http://selenium-grid.seleniumhq.org/
Actually using Grid you can automate the tests in parallel using a same machine or by using multiple machines (here machines in the sense of individual computers).
I hope this link will show you how to run a tests in parallel in same machine.
In the above given link the user said to create a five different programs to run in parallel. If you want to run single program in parallel, then just use TestNg or Junit to trigger multiple instance.
This is the sample TestNg config code to run a test in parallel. Here i ran two threads. So it will invoke the TestNg #Test method of a given class file com.test.workflow.device.testcase20 in two threads.
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite1" parallel="test" thread-count="2">
<test name="Testcase20" >
<classes>
<class name="com.test.workflow.device.testcase20"/>
</classes>
</test>
</suite>
By using above xml file you can acheive parallelism in webdriver using grid.
You could try with Sahi http://sahi.co.in/. It can run multiple instances of browsers in parallel.
Do look at how Sahi does file uploads though. http://sahi.co.in/w/_setFile
It's possible to run selenium instances concurrently. When selenium runs browser instances, it opens the connection on port 7055 by default.
So, if you want to run multiple instances, you have to run them on different ports.
I would suggest that you build a driver for each browser and let your code know that you use more than multiple drivers. Other suggestion as already described above, using Selenium Grid is the best solution available:
https://sqa.stackexchange.com/questions/5431/how-to-open-multiple-browsers-using-webdriver
https://github.com/SeleniumHQ/selenium/wiki/Grid2
if you use webdriver , try maven-surefire-plugin :
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<forkCount>4</forkCount>
</configuration>
</plugin>
</plugins>
in code use option 'forkCount' value 4 - number of processors. 4 processors = 4 JVM. U can start webdriver for each JVM !
link info http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html
I am try to run parallel test suites using below command.
java -cp testng-6.3.1.jar;test.jar;selenium-server-standalone-2.18.0.jar org.testng.TestNG -suitethreadpoolsize 2 testng-vm1.xml testng-vm2.xml
When i execute above command, the last testng xml file only (i.e testng-vm2.xml) is running. But i want to run both xml files parallel .
As i know that the above command is getting from http://testng.org/doc/documentation-main.html#parallel-tests
Please let me know is it possible to run parallel suites through TestNG?
I think it's a better solution by creating a Maven Project and configuring it to run your tests in parallel.
More details:
Starting with Maven
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
TestNG (and its parallel config)
http://maven.apache.org/plugins/maven-surefire-plugin/examples/testng.html