0

Is it possible to use a Test Object in the repository as a description object, to identify a collection of similar objects? I want to manage the identification of objects with discriptive programming, and thought of using TOs in repo as a way to identifty collections of objects.

If I have a TO in the repository that is not unique (that is, identifies a collection of similar objects), can I use that TO as a collection? How can I then identify a specific object from that collection?

EDIT: I'll provide more detail. I've been collecting objects with same characteristics with the Description Object and descripitive programming. For example, I identify an object thorugh its xpath:

Set oDesc = Description.Create
oDesc( "micclass" ).value = "WebElement"
oDesc ("xpath").value = "//DIV[14]/DIV[1]/DIV[1]"
Set colObject = ParentObject.ChildObjects(oDesc)

Alternatively, I can also store a TO in a repository that identifies the same object above (also using the same xpath value, "//DIV[14]/DIV[1]/DIV[1]").

Now consider the case where I want to identify a collection of objects:

Set oDesc = Description.Create
oDesc( "micclass" ).value = "WebElement"
oDesc ("xpath").value = "//DIV[14]/DIV[*]/DIV[1]"
Set colObject = ParentObject.ChildObjects(oDesc)

With descriptive programming, it returns a collection of objects with the following xpath values:

"//DIV[14]/DIV[1]/DIV[1]"
"//DIV[14]/DIV[2]/DIV[1]"
"//DIV[14]/DIV[3]/DIV[1]"
...

So, my question is: Is it possible to create/use a TO in a repository to identify/manage a collection of objects? For example, use a TO in the repository with the xpath "//DIV[14]/DIV[*]/DIV[1]"?

  • @user7253, WHY? do you need to use collection of objects. May be its not what you really need – Ivan Gerasimenko Mar 28 '16 at 7:51
  • I think I see what you are trying to do with this... But I'm not sure I understand why you would want to do it this way... besides, this is "Dangerously close to NOT using descriptive programming" ;) I'm a fan of using the OR - I only use DP when I don't know WHICH of my defined objects in the OR I'm looking for. – Trimble Epic Jun 6 '16 at 18:13
0

You can use regular expressions for description of your TOs in object repository. Open OR's window, select object, select object's property and click on the Value cell. Then you can see <#> button, click it and here is an option for usage of reg exp:

enter image description here

Your XPath expression would look this way: //DIV[14]/DIV[.*]/DIV[1]

Note: . is for substitution of any character and * is for occurrence count.

Warning: even with usage of regexp your identifier must be unique for displayed objects. If there are more than one object currently displayed in your application that matches the description, you'll get the next error:

enter image description here

So it will not be possible to get collection of objects on one page/window etc.

This case is just an error from UFT point of view, and could be handled by recovery scenario:

enter image description here

0

No. UFT generates an error every time it finds multiple objects matching the description.

Maybe consider why you want to create the collection in the first place.

I personally would argue against using DP because of higher maintenance cost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.