In the previous recipe, you have learned about using the Description
object. This recipe will show you how to get a collection of runtime objects and perform checkpoints to verify the values of specific properties. In our example, we will describe how to retrieve images from a web page, and then perform a check operation using a Checkpoint
object that we would store beforehand in OR.
Proceed with the following steps:
Description
object and then define the appropriate property-value pairs for identification, as follows:Dim oDesc, i, oImgCollection Set oDesc=Description.Create oDesc("html tag").value="IMG|img" oDesc("html tag").RegularExpression = true
set oImgCollection=Browser("title:=Google").Page("title:=Google").ChildObjects(oDesc)
Checkpoint
object to validate the required properties:For i = 0 To oImgCollection.count-1 oImgCollection(i).Check(Checkpoint("Image")) Next
The Description
object, oDesc
, was created to cover objects having the HTML tag img
. The page's ChildObjects
method uses the Description
object property's set definition to find a match with actual application (runtime) objects and returns a collection (array) of such objects. The items in this collection can be accessed using a zero-based index, as shown in the For
loop (in the previous section), and different operations, such as GetROProperty
and WaitProperty
, can be applied to them. It is important to stress that these are runtime objects, and hence, trying to apply the methods GetTOProperty
, SetTOProperty
, and GetTOProperties
is useless. This technique is useful when we need to perform a standard set of checks on different objects, as it optimizes our code syntax and allows for re-use of Checkpoint
objects. Moreover, it accommodates future changes in the application, as the procedure operates on dynamically retrieved objects.