While testing applications, you may need to get screenshots of some application controls (for example, combo boxes or list views), or images associated with certain controls (for example, the icon that is shown when a certain tree view item is selected). This topic describes how to work with images from keyword tests.
Getting Images
You can get the desired image in two ways - by capturing a screenshot of a certain control, or by getting an image corresponding to any control via a specific control’s properties.
You can capture a screenshot of the desired application control from the wizard of the Post Screenshot operation. For detailed information, see the operation’s description.
Obtaining images via specific object properties does not differ from getting property values of any other type. You can get the needed image using the Call Object Method, On-Screen Action or Run Code Snippet operation. For a detailed description of how to get the value of a certain property, see Getting Properties Values. Once you obtain the needed Picture
object, you can post it to the test log or process it in a certain way. For detailed information, see below.
Posting to the Log
TestComplete provides you with a specific Post Screenshot operation that you can use to post an image to the test log. For more information, see the operation’s description.
With the Post Screenshot operation you can either post a screenshot of the desired application control, or post a previously obtained Picture
object:
Posting Screenshots
To post a screenshot of the desired control, do the following:
-
Run the tested application.
-
Add the Post Screenshot operation to your keyword test. The Operation Parameters wizard appears.
-
Select the application object or object area whose image you want to log. You can either select the desired object or object area from screen or enter the object name manually.
-
If you want to specify the description for the screenshot, click Next to go to the next page of the wizard. Otherwise, click Finish to complete the wizard.
-
In the Message and, optionally, Additional Info fields, enter the descriptive text to be logged along with the image. The Message text will be displayed in the log’s Message column, while Additional Info will be shown in the log’s Details panel when the image is selected.
-
If you want to specify additional parameters of the operation (such as the priority of the posted message and so on), press Next and specify them on the next page of the wizard. Otherwise, press Finish.
Posting Previously Obtained Picture Objects
You can obtain a Picture
object via the specific properties of the object that corresponds to the tested control. For example, you can obtain a list view item’s image via the wImage
property of the Win32ListView
object. For detailed information on how to obtain property values from your keyword tests, see Getting Properties Values. To post the obtained Picture
object to the test log, do the following:
-
Add the Post Screenshot operation to your keyword test.
-
In the ensuing wizard, press Next twice to switch to the Operation Parameters page of the wizard.
-
Click the ellipsis button next to the Str parameter (it specifies the image to be posted). This will invoke the Edit Parameter dialog.
-
If the needed
Picture
object is returned by the previous operation, select Last Operation Result in the Mode box. -
If the previously obtained
Picture
object is stored in some variable (or parameter), select Variable (or Test Parameter) in the Mode box and then specify the needed variable (parameter) in the Value box. -
You can also select Code Expression or Onscreen Object in the Mode box and specify the property that will return the needed
Picture
object. For more information, see Specifying Operation Parameters.
-
Before calling the methods of the Region object, make sure that the Stores | Regions collection is added to your project. Otherwise, this object will be unavailable to your tests. |
See Also
Creating Keyword Tests - Common Tasks
Post Screenshot Operation
Picture Object