I've never user the eventHandler from Squish.
Instead of this (my problems is that all my objects are dynamic) I've created a custom wait function of mine. It works for all objects, no matter of their form/type.
This functions waits until an object is true.
def whileObjectFalse(objectID, log = True):
# functions enters in a while state, as long as expected object is FALSE, exiting when object is TRUE
# (default timeout of [20s])
start = time.time()# START timer
counter = 40
object_exists = object.exists(objectID)
while object_exists == False:
object_exists = object.exists(objectID)
snooze(0.5)
counter -= 1
if counter == 0:
test.fail(" >> ERR: in finding the object [%s]. Default timeout of [20s] reached!" % objectID)
return
if log == True:
elapsed = (time.time() - start)# STOP timer
test.log(" (whileObjectFalse(): waited [%s] after object [%s])" % (elapsed, objectID))
snooze(0.5)
So basicaly, your code will be like this:
def whileObjectFalse(objectID, log = True):
start = time.time()# START timer
counter = 40
object_exists = object.exists(objectID)
while object_exists == False:
object_exists = object.exists(objectID)
snooze(0.5)
counter -= 1
if counter == 0:
test.fail(" >> ERR: in finding the object [%s]. Default timeout of [20s] reached!" % objectID)
return
if log == True:
elapsed = (time.time() - start)# STOP timer
test.log(" (whileObjectFalse(): waited [%s] after object [%s])" % (elapsed, objectID))
snooze(0.5)
def main():
startApplication("myapp")
whileObjectFalse("NewDialog")
mouseClick(waitForObject(":MyButtonOnNewDialog"), MouseButton.LeftButton)