TestObject Class

Description

The base class of all UI objects.

Syntax

C#
public class TestObject, 
VB
'Declaration
Public Class TestObject

Properties

Name Description
Text The text of the control.
Value The value of the control, e.g.: text in a text control.

Methods

Name Description
CaptureBitmap Saves a bitmap image of this object to a file. If you do not specify an absolute file name, the bitmap is saved to the default bitmap location on the machine that runs the Agent, which is %LOCALAPPDATA%/Silk/SilkTest/capturedBitmaps. The captured bitmap's pixels are stored in 32bit RGB order; when parsing the image the 4th byte (alpha channel) of every pixel must be ignored as it is used only for padding. In .NET, the constant System.Drawing.Imaging.PixelFormat.Format32bppRgb can be used for this purpose.
Exists Checks if any child object matching the locator exists for an object in the application under test. If the timeout parameter is passed the agent retries finding until the given timeout expires. If no timeout is specified and no object is found initially false is returned immediately.
Exists Checks if an object exists in the application under test.
Find Finds an object specified by an XPath locator.
FindAll Finds all objects specified by an XPath locator.
GenerateLocator Returns a locator for this object.
GetChildren Returns the child objects of this object.
GetDynamicMethodList Returns a list of methods (including their signature) that can be dynamically invoked on this TestObject.
GetParent Looks up the parent of this object in the test application.
GetProperty Returns the value of the specified property.
GetPropertyList Returns a list of property names that can be retrieved for the given object.
GetRect Returns the size and position of this object. Per default the returned coordinates are relative to the parent window that contains this object.
HighlightObject Highlights this object.
ImageClick Clicks on the specified image asset.
ImageClickFile Clicks on the specified image.
ImageExists Returns whether the specified image asset exists.
ImageExistsFile Returns whether the specified image exists.
ImageRectangle Returns the object-relative rectangle of the specified image asset.
ImageRectangleFile Returns the object-relative rectangle of the specified image.
Invoke Dynamically invokes a method on the test object.
InvokeMethods Dynamically invokes a sequence of methods starting at this TestObject.
SetProperty Sets the value of the specified property.
StartScreenRecording Starts screen recording
StopScreenRecording Stops screen recording
TextCapture Returns the text in this object's visible area.
TextClick Clicks in the center of the specified text.
TextExists Returns whether the specified text exists.
TextRectangle Returns the object-relative rectangle of the specified text.
Verify Executes a verification on the given asset in the context of this UI object.
WaitForChildDisappearance Waits until the specified child object does not exist or until the timeout is reached. If you don't explicitly pass a timeout using the optional timeout parameter, the timeout specified by the option OPT_WAIT_RESOLVE_OBJDEF will be used. An exception is thrown if the timeout is reached.
WaitForDisappearance Waits until the object does not exist or until the timeout is reached. If you don't explicitly pass a timeout using the optional timeout parameter, the timeout specified by the option OPT_WAIT_RESOLVE_OBJDEF will be used. An exception is thrown if the timeout is reached.
WaitForObject 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.
WaitForProperty Waits until the specified property has the specified value or until the timeout is reached.If you don't explicitly pass a timeout using the optional timeout parameter, the timeout specified by the option OPT_WAIT_RESOLVE_OBJDEF will be used. An exception is thrown if the timeout is reached.
WaitForPropertyNotEquals Waits until the specified property has a value that is different to the specified value or until the timeout is reached.If you don't explicitly pass a timeout using the optional timeout parameter, the timeout specified by the option OPT_WAIT_RESOLVE_OBJDEF will be used. An exception is thrown if the timeout is reached.
WaitForScreenshotStable Waits until the control is visually stable and does not change its position, by comparing screenshots taken with the specified interval. If you don't explicitly pass a timeout using the optional timeout parameter, the timeout specified by the option OPT_WAIT_SCREENSHOT_STABLE will be used. The default interval is 200 milliseconds. An exception is thrown if the timeout is reached.