Update! Squish 6.1 introduced a more convenient way to set the default maximum time the waitForObject* functions wait for the object lookup to succeed.
Troubleshooting scripts, and don’t like waiting the entire timeout duration when an object isn’t found?
You can modify Squish API functions, and leave them with the same name, allowing you to alter the original API functions behavior.
- Modify the waitForObject function as follows:
def alterWaitForObject(waitForObjectFunction, defaultDuration):
def wrappedFunction(object, newDuration=None):
if newDuration is None:
newDuration = defaultDuration
retrievedObj = waitForObjectFunction(object, newDuration)
return retrievedObj
return wrappedFunction
- And from the main function, call the adjusted function:
def main():
startApplication("addressbook")
global waitForObject
waitForObject = alterWaitForObject(waitForObject, duration)
...