This blog is follow up from my previous one where I worked out an example to take screenshots on test failure. In this blog I am going to attempt to run the same tests however on multiple browsers and in parallel.
To achieve multi-browser parallel run of the test cases:
To achieve multi-browser parallel run of the test cases:
- I have updated the testng.xml and added config to run the tests in parallel with browser_type parameters each with its own thread, one for firefox and one for chrome.
- Updated pom.xml to start using testng.xml file to kickoff the test cases.
- Updated WebDriverManager class to be thread aware and return correct WedDriver (Firefox or Chrome) instance so that in case of test failure screenshot of correct browser can be taken.
- Minor tweak in the test case so that its aware of which browser type to run with.
The entire project is uploaded on github for reference: https://github.com/njaiswal/council-tax-band
Right, lets get to the nuts and bolts now.
testng.xml
Two test cases in the suite, TestNG will run these 2 test case with a threadpool size of 2, which means that both browsers will fire-up at almost the same time and go through the test cases in parallel which saves us time!
pom.xml (snippet)
Above pom.xml snippet tells maven to start using testng.xml to kick off the test cases. Please refer full pom.xml on github
WebDriverManager
WebDriverManager is a bit more meaty than previous blog. Instead of keeping the WebDriver instance as static variable it has a static HashMap in which it will store thread Id as the key and the WebDriver instance as value. Since our tests are now going to run on more than 1 thread we need this arrangement so that WebDriverManager knows which instance to return to onTestFailure() method based on the Thread Id.
CTaxBandTest (snippet)
As you can see above I have used the @Parameters annotation along with @BeforeClass. This basically fetches parameter browser_type from the testng.xml file and passes it as method parameter to onTimeSetUp() method. This is a key step where we call WebDriverManager.startDriver() and get correct browser instance created. As mentioned above, WebDriverManager will store the instance reference in a HashMap with thread Id as key so that any future calls to WebDriverManager.getDriverInstance() can identify which browser instance to return.
Reports
Run the tests using 'mvn test' command and you should see 2 browser instances (Firefox and Chrome) getting started at the same time and the tests being run in parallel.
Two reports get generated (one for each browser type) with total of 4 test cases being run and more importantly both contain correct screenshots of test failures.
Again the entire project is on git hub for reference, happy testing!
I have multi module project, one of them is a common project that contains WebDriver setup. in each module I have different testng.xml file.
ReplyDeleteWhen running 'mvn test' I'm getting error "Parameter 'browser' is required by @Configuration on method setUp but has not been marked @Optional or defined"
It look like it did not get parameters from testng.xml file
Can you please help me ? Thanks
The blog gave me idea to Run Selenium tests in parallel on multiple browsers My sincere thanks for sharing this post and please continue to share this post
ReplyDeleteSelenium Training in Chennai
really nice blog has been shared by you. before i read this blog i didn't have any knowledge about this but now i got some knowledge. so keep on sharing such kind of an interesting blogs.
ReplyDeleteselenium training in chennai
This is my first time i visit here. I found so many interesting stuff in your blog. keep up the good work. Thanks for sharing this useful information for our vision.
ReplyDeleteSoftware Testing Training in Chennai
Selenium Training in Chennai
Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.Nice article i was really impressed by seeing this article, it was very interesting and it is very useful for me.
ReplyDeleteDot Net Training in Chennai | Python Training in Chennai | Web Designing Training in Chennai
Great posting! Nice to know the performance difference between scrapy and selenium. Thanks.
ReplyDeleteSelenium Training in Bangalore
This is my first time i visit here. I found so many interesting stuff in your blog. keep up the good work. Thanks for sharing this useful information for our vision.
ReplyDeleteSelenium Training in Chennai
Webtrackker is one only IT company who will provide you best class training with real time working on marketing from last 4 to 8 Years Experience Employee. We make you like a strong technically sound employee with our best class training.
ReplyDeleteWEBTRACKKER TECHNOLOGY (P) LTD.
C - 67, sector- 63, Noida, India.
F -1 Sector 3 (Near Sector 16 metro station) Noida, India.
+91 - 8802820025
0120-433-0760
Best SAS Training Institute in delhi
SAS Training in Delhi
SAS Training center in Delhi
Best Sap Training Institute in delhi
Best Sap Training center in delhi
Sap Training in delhi
Best Software Testing Training Institute in delhi
Software Testing Training in delhi
Software Testing Training center in delhi
Best Salesforce Training Institute in delhi
Salesforce Training in delhi
Salesforce Training center in delhi
Best Python Training Institute in delhi
Python Training in delhi
Best Python Training center in delhi
Best Android Training Institute In delhi
Android Training In delhi
best Android Training center In delhi
Thanks for sharing such an informative blog. I have read your blog and I gathered some needful information from your post. Keep update your blog. Awaiting for your next update.
ReplyDeletesap abap online training india
Sap fico training institute in Noida
ReplyDeleteSap fico training institute in Noida - Webtrackker Technology is IT Company which is providing the web designing, development, mobile application, and sap installation, digital marketing service in Noida, India and out of India. Webtrackker is also providing the sap fico training in Noida with working trainers.
WEBTRACKKER TECHNOLOGY (P) LTD.
C - 67, sector- 63, Noida, India.
F -1 Sector 3 (Near Sector 16 metro station) Noida, India.
+91 - 8802820025
0120-433-0760
0120-4204716
EMAIL: info@webtrackker.com
Website: www.webtrackker.com
android training center in noida sector 62
ReplyDeletedigital marketing training center in noida sector 15
python training in noida sector 63
sap sd training in noida
devops training in noida
sap sd training center in noida
ReplyDeletelinux training center in noida sector 62
Email marketing training course in noida sector 15
salesforce training in noida sector 63
openstack training in noida sector 15
machine learning training in Noida sector 62
AWS training institute center in Noida sector 63
ReplyDeleteandroid training center in noida sector 15
salesforce training in noida sector 18
sap sd training course in noida
sap fico training in noida
Visit Bharat Go Digital Academy to learn the digital marketing skills in India.
ReplyDeleteSmm Panel
ReplyDeleteSmm panel
iş ilanları
İnstagram takipçi satın al
https://www.hirdavatciburada.com/
HTTPS://WWW.BEYAZESYATEKNİKSERVİSİ.COM.TR/
servis
tiktok para hilesi indir