Squish tip of the week: Modify default waitForObject duration

Squish tip of the week: Modify default waitForObject duration

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.

  1. 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
  2. And from the main function, call the adjusted function:
    def main():
        startApplication("addressbook")
        global waitForObject
        waitForObject = alterWaitForObject(waitForObject, duration)
        ...

For more details, see Modify waitForObject Default Duration