Action
Waits for an object that matches the specified locator. If no object matches within an timeout an ObjectNotFoundException
is thrown. The default timeout is 5 seconds and you can change the timeout by setting the value of the option OPT_WAIT_RESOLVE_OBJDEF. Use WaitForObject if the AUT takes a long time to display a specific object, for example when a transaction is processed
before showing any results. By default, an action in the UI does not require a WaitForObject, because of the built-in synchronization.
If you receive random timeout errors during normal script execution, consider increasing the default timeout instead of adding
WaitForObject statements to your scripts.
Syntax
testObject.WaitForObject(locator, [timeout])
Variable |
Description |
locator |
The XPath locator. Defines which object to find. Example:
"//PushButton[@caption='ok']" . String.
|
timeout |
Optional: The timeout in milliseconds. If the initial find operation does not match anything the agent retries to find an object until
the timeout expires. Integer.
|
Examples
The following example sets a window active, then waits for a button for 30 seconds,
in addition to the timeout used for the
PushButton method to find the object, which by default is 5 seconds, and finally clicks the button:
window.SetActive()
window.WaitForObject("//PushButton[@automationId='MySampleButton']", 30000)
window.PushButton("@automationId='MySampleButton'").Click()