I'm writing the Selenium test cases for each screen to test the different scenarios. In our project for each build in Jenkins, its Selenium test cases (QA) also runs automatically.
My problem is even though it's automated, it's taking a lot of time to run. I have 380 test cases and it's taking 20-25 minutes. How can I reduce the time? Are there any other ways or techniques to follow?
you can check for the Selenium grid option, which will help you to run the tests in parallel.
http://selenium-grid.seleniumhq.org/
In the 380 testcases you have , check if all the testcases are really required . If all the testcases are required , check if u are having any repeated validations and see if you can remove any one of them .
If you are using wait time in your testcases , see if you can reduce the wait times with out affecting the output of the testcases .
The best thing would be to split them in to seperate groups and run them in different machines using Grid . Or use TestNg/JUnit to run the testCases parallely .
In TestNg , in the testng.xml file , u can use the following to run them in parallel
<suite name="ParallelTests" verbose="5" parallel="methods" thread-count="10">
Related
I came across this question:
How can I run multiple tests in parallel with JS/nightwatchjs?
But I want to execute multiple tests in parallel in the chrome browser only, in multiple chrome driver sessions.
I am used to java-testng-selenium based test suites where I can specify in the testng.xml file that I want to run multiple test classes or test methods in parallel and the framework does that exactly. If I specify in testng.xml that I want multiple test methods to execute in parallel in 4 threads, 4 chrome browser sessions pop-up and 4 test methods are executed in parallel.
Here's an example with a thread-count=2: https://github.com/adityai/testng-parallelsample/blob/master/methods-test-testng.xml
How can I do the same with nightwatch.js?
You might want to try the test_workers configuration, although I haven't tried it myself it should do exactly what you are looking for.
And a nice article that demostrates it in action:
https://markus.oberlehner.net/blog/speeding-up-nightwatch-powered-acceptance-tests/
I have a selenium java code which executes tests on IE. I want to try executing these tests in parallel using the same browser. How can I achieve this? And will I need to use multiple nodes to do so?
You need to setup a selenium grid which has atleast 2 nodes attached to it.
When it comes to IE support, you can run ONLY 1 test at any given point in time on one selenium node.
So if you need to run two parallel IE tests, then you would need to have atleast 2 nodes attached to your grid.
This blog post of mine gives you a complete overview of the selenium grid.
https://rationaleemotions.github.io/gridopadesham/
I have a small collection of integration tests that utilize selenium in a class. The idea is that these tests run every time there is a merge to the codebase, with the merge proceeding through the pipeline and having a series of tests running against the new code.
The thing is, these selenium tests have to run one at a time. They're using the browser to log into a website, and the account will just log out if more than one person tries to log into the account at once, it'll just log out, and the test will obviously fail, so I need these tests to run one at a time. I've tried using the #NotThreadSafe annotation, doesn't seem to have changed anything, and I've searched through for some sort of switch or parameter that defines how many tests run at once with no luck. These tests are using junit 4.12.
I'm trying to simulate a firefox load testing situation. I want my to test how 10 simultaneous logins would play out on my system. I already have a connected selenium grid hub and 10 open nodes.
So far, I know I can write the test case and run it 10 times which isn't what I need because it isn't automated. I also know that I can use invocation count on the test to make it run as many times as i want but this only works on the same browser node.
Does anyone have any ideas on how to automatically distribute the same test case to multiple instances of the same driver profile?
i.e. Run a login case test times on the same firefox profile open in 10 different nodes in parallel.
Gracias!
P.S. I built my tests using testNG if that matters.
Basically selenium and testNG is not for such requiurement. You should use some dedicated tool for that like jmeter.
However you can run n methods parrallel let say if you want to login with 10 dif user in 10 thread/browser you can create test data driven and configure to run method in parrallel. Make sure you are providing proper value of parrallel thread count.
How about combining threadpoolsize with invocationcount. - http://testng.org/doc/documentation-main.html#parallel-running
Grid would take care to distribute on the 10 nodes.
use headless browser like GHOST and then invoke multiple threads as ghost has no UI so it would work in your case
I have selenium test that takes 1 minute to complete . If I want to run this 1000 times I have to wait 16 hours . Is there any way I can run 5 tests in parallel so that it can be done in 3 hours ? I have generated a JUnit test scrip and tried to run in with multiple threads but they end up using the same Firefox window . I don't want to run this on grid cause running 5 Firefox window is not that resource intensive.
Thanks
By using below logic you can run your junit cases in parallel.
Class[] cls={test1.class,test2.class,test3.class,test4.class};
JUnitCore.runClasses(new ParallelComputer(true,false),cls);
In above method first parameter of ParallelComputer() indicates classes and second one is for methods. Here I'm running classes in parallel but not methods.
ParallelComputer Class documentation
http://junit-team.github.io/junit/javadoc/4.10/org/junit/experimental/ParallelComputer.html
Try with this example
http://mycila.googlecode.com/svn/sandbox/src/main/java/com/mycila/sandbox/junit/runner/
The file to launch is MySuite.java. Works well for me.