selenium - How to continue test execution after assertion failed? -


i know question duplicate one. searching result yesterday. didn't got solution that.. using selenium webdriver 2.47.1 & testng automation. in automation script have 12 set of tests & using testng assert method compare expected result & actual result. code format given below...

@test(priority = 6) public void testingenote1() {    cd.switchto().frame("rtop");    cd.manage().timeouts().implicitlywait(20, timeunit.seconds);    string testenote1 = cd.findelement(by.xpath("//table/tbody/tr[2]/td[5]")).gettext();    stringbuffer object1 = new stringbuffer(testenote1);    string actenote1 = object1.substring(108);    string expenote1 = ex.getexcelvalue(scenarioname, 75, 4);    try {        assert.assertequals(expenote1, actenote1);        ex.setexcelvalue(scenarioname, 75, 8, "passed");    }    catch(exception e) {          ex.setexcelvalue(scenarioname, 75, 8, "failed");    }    cd.switchto().defaultcontent(); } 

execution of test script stops once assertion got failed. want continue execution after assertion fail also. have used verify() also, gives verify result passed. above test result failed one.

i'd recommend using try/finally block.

. . .

    try {      //use if condition match strings (expenote1, actenote1)are equal       ex.setexcelvalue(scenarioname, 75, 8, "passed");      }      catch(exception e)      {  ex.setexcelvalue(scenarioname, 75, 8, "failed");}      {  cd.switchto().defaultcontent();} 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -