Automation Using Selenium Webdriver
Showing posts with label Execute Failed test cases using selenium Real-time Example. Show all posts
Showing posts with label Execute Failed test cases using selenium Real-time Example. Show all posts

Monday 10 October 2016

Execute Failed test cases using selenium Real-time Example

Most of the time we have faced this question in interviews that Can we execute only failed test cases in Selenium or can we identify only failed test cases in Selenium and re-run them.



I really love this feature of TestNG that you can run only failed test cases explicitly without any code. This can be easily done by running one simple testng-failed.xml.


                                    Execute Failed test cases using Selenium
                                           Real-time Example


Take an example that you have one test suite of 100 test cases and once you start execution of test suite there  are a number of chances that some test cases will fail.Consider 15 test cases are failing out of 100 now you need to check why these test cases are failing so that you can analyze and find out the reason why they have failed.

Note- Your script can fail due to so many reasons some of them are

1- Some locator has been changed in application because the application is getting new feature- so in this case you need to modify your script in other words you have to refine your script.

You can not avoid maintenance of test script you always have to maintain your scripts
2- Either functionality has been broken- in this case, you have to raise a defect and assign to the respective person.

Execute Failed test cases using Selenium
Steps

1-If your test cases are failing then once all test suite completed then you have to refresh your project . Right click on project > Click on refresh or Select project and press f5.

2-Check test-output folder, at last, you will get testng-failed.xml

3- Now simply run testng-failed.xml.


           

How to run testng-failed.xml
We don’t have to perform any other activity once you will  get testng-failed.xml double click on this and analyze which test case are failing and why . Then modify your script and run it.

To run above xml simple right click on xml then Select run as then TestNG Suite.


or more info visit TestNG official website
Thanks for visiting my blog. Keep visiting.
Please comment below if you finding any issue. Have a nice day ðŸ™‚