Where to place Finally with try catch block in java -
Where to place Finally with try catch block in java -
i'm test web application finding element webdriver , want know if first element not found want go on executing sec code, placed code, after placeing finally, code stops execute , did not go on sec step.
please help, give thanks here code:
// ---first step----------------------------------------- seek { driver.findelement(by.classname("label")).isdisplayed(); system.out.println(" label displayed"); } grab (nosuchelementexception e) { system.out.println("label not displayed"); } { system.out.println("go next step"); } driver.findelement(by.classname("label")).click(); thread.sleep(3000); // ---second step------------------------------------------ seek { driver.findelement(by.linktext("resumé")).isdisplayed(); system.out.println("resumé displayed"); } grab (nosuchelementexception e) { system.out.println("resumé not displayed"); } { system.out.println("go next step"); } driver.findelement(by.linktext("resumé")).click();
in first step click on label when element present. click action outside of seek grab block. moved both click action in try
try { driver.findelement(by.classname("label")).isdisplayed(); system.out.println(" label displayed"); driver.findelement(by.classname("label")).click(); } grab (nosuchelementexception e) { system.out.println("label not displayed"); } **finally { system.out.println("go next step"); }** thread.sleep(3000); //---second step------------------------------------------ seek { driver.findelement(by.linktext("resumé")).isdisplayed(); system.out.println("resumé displayed"); driver.findelement(by.linktext("resumé")).click(); } grab (nosuchelementexception e) { system.out.println("resumé not displayed"); } **finally { system.out.println("go next step"); }**
java
Comments
Post a Comment