Find Method (TestObject)

Class

TestObject.

Action

Finds an object specified by an XPath locator or an object map identifier. 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 Options.ObjectResolveTimeout, expires. If no object is found an ObjectNotFoundException is thrown. You can set the Options.ObjectResolveTimeout option in the General page of the Options dialog box. The option is called Default wait timeout (milliseconds) in the UI. The default value for the timeout is 5 seconds.

You can use the Pushbutton or Window method instead of Find. For instance, you can type:
myWindow.Find(Of PushButton)("//PushButton[@caption='ok']").Select()
Or:
myWindow.PushButton("@caption='ok'").Select()
When using object maps, the corresponding object map identifier is ok, and the previous code samples look like the following:
myWindow.Find(Of PushButton)("ok").Select()
Or:
myWindow.PushButton("ok").Select()

Syntax

TestObject.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. Can be used to override the default timeout or to specify that null (nothing in Visual Basic) should be returned if no object is found instead of throwing an exception.