mercredi 23 décembre 2020

How to handle failed step in Selenium automation

I am Automating a web application which is customizing a product online. We have scenarios for chairs and table creation. Application consist of a "Reinitialize" button on each step. Role of this button is to get back on first question to start the customization again. In between of first and last step we have a proceed button to continue answer the next customizing question and at the end we validate Price of that product. I am using Selenium with Junit, Suppose my step fails due to Xpath failure or text mismatch, how should i proceed further to mark that scenario as fail and continue to check next scenario. In my current test format, i am using methods to select the answers and after verifying price i am clicking Reinitialize button to next scenario, but if Xpath fails of one step, it fails whole test, please suggest which approach i should use here.

Test.class

for (String i : keys) {
            System.out.println("########### Test = " + win.get(i).get(0) + " ###########");
            MainPage.EnterTaille(win.get(i).get(1));
            MainPage.SelectCONFIGURATION(win.get(i).get(2));
            MainPage.SelectPLANVASQUE(win.get(i).get(3));
            MainPage.SelectCOULEUR(win.get(i).get(4));
            MainPage.SelectPOIGNEES(win.get(i).get(5));
            MainPage.SelectTYPE_DE_MEUBLE(win.get(i).get(6));
            MainPage.ClickCREAMIXReinit();
            test1.pass("Scenario " + win.get(i).get(0) + " is passed");
            System.out.println("########### Test End ##############");
            extent.flush();
        }

        test.setResult("pass");
    

Aucun commentaire:

Enregistrer un commentaire