• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Home
  • Programming Languages
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
  • Automation Tools and Different Tools
    • Web Automation
      • Selenium with Java
        • Selenium Basic
        • Selenium Advance
        • Selenium Realtime
        • Framework
        • Selenium Interview
        • Selenium Videos
        • Selenium with Docker
      • Selenium with Python
      • WebdriverIO
        • Selenium Webdriver C# Tutorial
      • Cypress
      • Playwright
    • TestNG
    • Cucumber
    • Mobile Automation
      • Appium
    • API Testing
      • Postman
      • Rest Assured
      • SOAPUI
    • testRigor
    • Katalon
    • TestProject
    • Serenity BDD
    • Gradle- Build Tool
    • RPA-UiPath
    • Protractor
    • Windows Automation
  • Automation For Manual Testers
  • Services
  • Online Training
  • Contact us
  • About me
  • Follow us
    • Linkedin
    • Facebook Group
    • Facebook Page
    • Instagram

Automation

Selenium WebDriver tutorial Step by Step

You are here: Home / TestNG Tutorial / Simple way to execute failed test cases using Selenium

Simple way to execute failed test cases using Selenium

March 21, 2015 by Mukesh Otwani 12 Comments

Execute Failed test cases using Selenium

Hello Welcome to Selenium tutorial, Today we are going to discuss how to Execute failed test cases using Selenium

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.

 Execute Failed test cases using Selenium

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.

 

I have  the Youtube video for the same. Kindly check.

 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.

 

 Execute Failed test cases using Selenium

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.

 

 Execute Failed test cases using Selenium

For 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 🙂

 

 

 

 

 

 

 

Filed Under: TestNG Tutorial Tagged With: Execution of failed test case

Reader Interactions

Comments

  1. Chittaranjan says

    February 14, 2017 at 11:01 AM

    Hi Mukesh ,
    How can we implement like it will run testng-failed.xml automatically after completion of first suite execution .

    Reply
    • Mukesh Otwani says

      February 16, 2017 at 11:38 AM

      Hi,

      This will help http://learn-automation.com/re-run-selenium-failed-test-cases/

      Reply
  2. harshal says

    February 7, 2017 at 11:25 AM

    if out of 10 testcases 3 are failed. if we run 3 failed test cases after maintance then all 10 test cases will run or only 3. Here execucation of test case3s are depend on passed test cases

    Reply
    • Mukesh Otwani says

      February 16, 2017 at 11:45 AM

      It will run only failed 3 test cases.

      Reply
    • Atitkumar Shingatalur says

      October 16, 2019 at 9:56 PM

      When we try to run a test by right clicking on it which is dependent on another test and that test is dependent on another test
      Ex: test3 depends on test2 & test2 depends on test1.
      So here if I right click and run test3 it will not execute Bcz it has multilevel dependencies.

      So my question is when we execute the suite and only test3 failed in that case failed-test.xml will have included only test3. Will it run the test3 alone, Bcz it depends on test2 & test2 depends on test1.

      Reply
      • Mukesh Otwani says

        October 18, 2019 at 1:04 AM

        Hi Harsha,
        It should run all 3 test.

        Reply
  3. Gaurav Khurana says

    January 15, 2017 at 2:48 PM

    Oh thats so easy. If we open that file we can see that just like testng.xml has the configuration to run all cases.

    testng-failed.xml contains information for which cases to be run.

    First thanks to Test-NG and then to you Mukesh for making things so simple

    Reply
    • Mukesh Otwani says

      January 24, 2017 at 4:10 PM

      Correct gaurav and I also want to thanks to you to provide always nice comment and feedback.

      Reply
  4. sujtih says

    June 7, 2016 at 5:43 PM

    Hello sriram,

    if non of attributes are not available, it is better to goes with xpath or CSS selector.

    -Alunkal

    Reply
  5. sriram says

    March 10, 2016 at 12:00 AM

    Hi Mukesh, Thanks for the information.

    Could you please help me how we can solve below question.

    Q: I have username and password filed and I have only ID or Name something for user name but not for Password. But I want enter the data into password filed how we can achieve this. Could you please help me to slove this one. Thanks in advance.

    Reply
  6. Siddharth says

    December 18, 2015 at 9:47 AM

    Hello Sir,
    I am facing problems while using “annotations of TestNG”. I am getting fully confused.
    Would you please guide me & Give some examples of every annotations where to use.
    So that i can follow those examples for my future reference.
    Waiting for your valuable response.

    Thanks & Regards,
    Siddharth

    Reply
    • Mukesh Otwani says

      December 20, 2015 at 11:57 PM

      Hi Siddhharth,

      I can understand 🙂 will upload an article on this soon.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Free Selenium Videos

https://www.youtube.com/watch?v=w_iPCT1ETO4

Search topic

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?

Stay connected via Facebook

Stay connected via Facebook

Archives

Footer

Categories

Recent Post

  • API Testing Using Postman And RestAssured
  • Disable Personalise Your Web Experience Microsoft Edge Prompt In Selenium
  • How To Fix Error: No tests found In Playwright
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Best and easy way to Group test cases in selenium

Top Posts & Pages

  • Selenium Webdriver tutorial for beginners
  • How To Fix Eclipse Autocomplete Or Code Suggestion In Eclipse
  • Selenium Webdriver C# Tutorial
  • WHAT ARE YOUR EXPECTATIONS FROM US?