AnyWin class.
Finds an object specified by an XPath locator.
This function is supported only in scripts that use the Open Agent and dynamic object recognition.
window.Find(locator [, options])
Variable | Description |
---|---|
locator | The XPath locator or object map identifier. Defines which object to find. STRING. |
options | Optional: Specifies options for the Find operation. Use to override the default timeout value or to specify whether a E_WINDOW_NOT_FOUND exception is thrown if no object is found (default) or if NULL is returned if no object is found. FINDOPTIONS. |
Returns the first object that matches the locator. As long as no object matches the locator, the agent tries to find an object until the default timeout, which is specified by the option OPT_WINDOW_TIMEOUT, expires. If no object is found an E_WINDOW_NOT_FOUND exception is thrown. In the UI, you can set the OPT_WINDOW_TIMEOUT option in the Timing tab of the Agent Options dialog box. The option is called Window timeout (seconds). The default value for the option is 5 seconds.
An E_INVALID_XPATH exception is thrown if the XPath locator is syntactically incorrect. You can record the XPath query string if necessary.
[-] WINDOW getOkButton(WINDOW dialog) [ ] return dialog.find(".//PushButton[@caption = 'Ok']")When using object maps, the corresponding object map identifier is ok, and the previous code samples look like the following:
[-] WINDOW getOkButton(WINDOW dialog) [ ] return dialog.Find("Ok")
WINDOW informationDialog = Desktop.Find("//Dialog[@caption=’Information’]") WINDOW okButton = informationDialog.Find("//PushButton[@caption='ok']") okButton.Click()When using object maps, the corresponding object map identifiers are Information and ok, and the previous code samples look like the following:
WINDOW informationDialog = Desktop.Find("Information") WINDOW okButton = informationDialog.Find("ok") okButton.Click()
WINDOW informationDialog = Desktop.Find("//Dialog[@caption=’Information’]", {3,FALSE})When using object maps, if the corresponding object map identifier is Information, the previous code samples look like the following:
WINDOW informationDialog = Desktop.Find("Information", {3,FALSE})