In some cases, a TO may appear repeatedly on a window or page. A common example is images that are used as buttons in web applications. If a function is called to perform an action on such a TO, we may need to ensure that the correct object was passed. A powerful technique to achieve this is already outlined in the Identifying elements based on anchors recipe in Chapter 2, Testing Web Pages. In this recipe, we will see how to do it according to the object's parent (such as a Frame
or WebTable
, but can also be any WebElement
), which is the container that holds our target TO.
Suppose that we have a reference to an OR TO and need to perform an operation or checkpoint using it and that we know the description of its container object. We can then write the following function that will indicate whether the target TO is the one we were looking for, based on its parent:
Function IsObjectByParent(ByVal obj, ByVal oDicProps) Dim bParent, oParent...