Look into Ruby's Begin/rescue/ensure/end Just Google 'ruby begin rescue ensure' for details
In a nutshell its format is... begin # Code you want to trap errors on goes here # such as your assert statement rescue # code to deal with errors goes here # such as calling your screen capture method # code here is only executed if code in the begins section fails ensure # code that is executed after the code in the begin passes or fails # also runs if the code in the rescue was executed (if neccessary) end Hope that helps, Joe On Aug 24, 1:33 am, Dmitri Karusar <flysteppe...@gmail.com> wrote: > Hi. > > Can't make it running, if assertion failed then to capture screenshot. > I got a solution how to capture screenshot: > > def screen_capture > ... > ... > end > > Then I check in script: > assert($ie.frame(:name,"mainFrame").contains_text("Object saved"), "+++ > +++FAILED! Changes were not saved") > > And if this assertion is failed I want to call "screen_capture" > > Can you help, how to implement this ? > BR, > Dmitri -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com