Exception Handling:
find
operations (explicit
and
implicit)
when not successful raise an Exception
FindFailed,
that
will
stop the script immediately.
For
more sophisticated concepts, you can implement your own exception
handling using the standard Python construct try:
... except: ... .
AssertionError:
When it encounters an assert statement, Python evaluates the
accompanying expression, which is hopefully true. If the expression
is false, Python raises an AssertionError exception.
Sample Code:
import sys, os
def TestOne():
App.focus("fieldworks")
find("1477810460138.png").highlight(2)
find(Pattern("1477810513968.png").targetOffset(28,0)).right(250).click()
type("Testing")
wait(2)
assert exists("Testing.png")
try:
TestOne()
except (AssertionError, FindFailed) as e:
#print str(sys.exc_info())
print "Print Error stack lines... " + str(e)
Sample Code:
import sys, os
def TestOne():
App.focus("fieldworks")
find("1477810460138.png").highlight(2)
find(Pattern("1477810513968.png").targetOffset(28,0)).right(250).click()
type("Testing")
wait(2)
assert exists("Testing.png")
try:
TestOne()
except (AssertionError, FindFailed) as e:
#print str(sys.exc_info())
print "Print Error stack lines... " + str(e)
No comments:
Post a Comment