java - How can I continue the test flow even if the element cant be located in Selenium? -


i getting input data excel sheet, iterate rows using for-loop.

if suppose element not found, flow stops. want continue flow taking screenshot @ page failed move on next.

i tried using below method:

@aftermethod public void teardown(itestresult result) {     if (itestresult.failure == result.getstatus()) {         try {             takesscreenshot ts = (takesscreenshot) driver;             file source = ts.getscreenshotas(outputtype.file);             fileutils.copyfile(source, new file("d:\\screenshot" + result.getname() + ".png"));             system.out.println("screenshot taken");         } catch (exception e) {             system.out.println("exception while taking screenshot " + e.getmessage());         }     } }      

i input separate class, how can continue for-loop without interrupting flow of loop.

hope made clear.

thanks in advance.

try catch need inside loop , if catches take screenshot , continue next element in loop

for(...) {    try    {       //your code excel    }    catch(exception ex)    {       //if throwing exception take screenshot    } } 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -