Is there a way to continue testing after an image fails to match?

37 views
Skip to first unread message

JB

unread,
Dec 13, 2017, 5:46:43 AM12/13/17
to stb-tester
Hi All,

I need some hep trying to figure this out. Currently I'm trying to match a set of images along with a couple of simple key presses. What I want my script to do is continue testing even after an image fails to match. 

When testing, if an image fails to match, my test falls over and I haven't to run the test script again from the command terminal. I have tried using the "stbt batch run -k" in the command terminal but that appears to skip to the next test section of my script.


Any help resolving this would be appreciated.

Thanks, 

John. 

Rinaldo Merlo

unread,
Dec 13, 2017, 6:06:39 AM12/13/17
to stb-tester
The usual way in python would be to catch the exception that is otherwise aborting your script by putting it inside a try...exception block, something like this:

try:
    stbt.wait_for_match('myimage.png')
except:
    print ("Image failed to match")

JB

unread,
Dec 13, 2017, 8:46:37 AM12/13/17
to stb-tester
Thanks for the reply. Would this create a failure in the index.html?

Rinaldo Merlo

unread,
Dec 13, 2017, 8:48:49 AM12/13/17
to stb-tester
Not sure about that, sorry, I don't actually use the batch run.

Lewis Haley

unread,
Dec 14, 2017, 4:52:35 AM12/14/17
to stb-tester
Instead of using `wait_for_match` you can do

if stbt.wait_until(lambda: stbt.match('yourimage.png')):
    handle_success()
else:
    handle_failure()

Either way, `stbt` only reports fatal errors, i.e. unhandled exceptions that cause the test script to terminate.
Reply all
Reply to author
Forward
0 new messages