Squish tip of the week: Modify default waitForObject duration

Squish tip of the week: Modify default waitForObject duration

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.

  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)
        ...

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*