Highlighted
Super Contributor.
Super Contributor.
2217 views

How does "Set X = Description.Create( )" actually work?

Jump to solution

I inherited the Tester role from a master of UFT when he left to move to another state.

His scripts make extensive use of code blocks like:
Set X = Description.Create( )
    X("micclass").Value = WebElement
    X("class").Value = "ui-tooltip ui-widget ui-corner-all ui-widget-content"
Set objX = Browser("B").Page("P").ChildObjects(X)
and then objX is used extensively in lines like:
Result = objX(0).GetROProperty("innertext")
InputSource = Mid(Result, InStr(Result, "Input src") + 10)
et cetera

The Test has 81 WebElement in the OR.
Which of them is in focus by the lines:
    X("micclass").Value = WebElement
    X("class").Value = "ui-tooltip ui-widget ui-corner-all ui-widget-content"
?

I've spent 3 days reading many pages of a web search on "uft Description.Create" and related web queries, and am no closer to understanding how the ambiguity of which WebElement is being selected by the script code.

I also read extensively in the UFT Object Method manual (a web link) that somebody on this web forum posted in my previous thread post.

I did learn a lot about the ui- codes though! "ui-corner-all" is a clever one.

Does anyone have either an explanation or a link to an explanation of how this works?
Thanks in advance.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Honored Contributor.
Honored Contributor.


Set objX = Browser("B").Page("P").ChildObjects(X)
and then objX is used extensively in lines like:
Result = objX(0).GetROProperty("innertext")
InputSource = Mid(Result, InStr(Result, "Input src") + 10)

 

Description.Create has always worked for me and we use it a lot. 

Set X = Description.Create( )
    X("micclass").Value = "WebElement"
    X("class").Value = "ui-tooltip ui-widget ui-corner-all ui-widget-content"

In the first line you are actually creating a description object.  

Second line = you are saying the object's micclass value is "WebElement"

Third line = you are saying the objects's class value ( as in dom) is "ui......"

So, how it works is it will filter all the objects on the page to the specifics on line 2 and 3. First, it will collect all webelements and then it will filter the webelements based on the class value you have mentioned. 

I dont think you would use it when you already have objects in the OR. You would use description object, when you want to identify and work on objects at run time, generally the objects not in OR. Example, a list that is not getting identified as a list, and then all the dropdown options of that list are webelements ( we cant add all options of a drop down list to the OR) so in such cases, you would use description object to identify the options of the drop down list at run time and select or work on it.

If you want to see what objects are getting identified, you can just add a highlight step as shown below to see the object that it is working on and also see the innertext at runtime. 

Set objX = Browser("B").Page("P").ChildObjects(X)

For i=0 to objX.count-1

   objX(i).highlight

   Result = objX(i).GetRPProperty("innertext")

Next

Hope this helps.

View solution in original post

6 Replies
Highlighted
Super Contributor.
Super Contributor.

Ooops!

The line:
    X("micclass").Value = WebElement
should have been
    X("micclass").Value = "WebElement"

Sorry for the typo.

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.


Set objX = Browser("B").Page("P").ChildObjects(X)
and then objX is used extensively in lines like:
Result = objX(0).GetROProperty("innertext")
InputSource = Mid(Result, InStr(Result, "Input src") + 10)

 

Description.Create has always worked for me and we use it a lot. 

Set X = Description.Create( )
    X("micclass").Value = "WebElement"
    X("class").Value = "ui-tooltip ui-widget ui-corner-all ui-widget-content"

In the first line you are actually creating a description object.  

Second line = you are saying the object's micclass value is "WebElement"

Third line = you are saying the objects's class value ( as in dom) is "ui......"

So, how it works is it will filter all the objects on the page to the specifics on line 2 and 3. First, it will collect all webelements and then it will filter the webelements based on the class value you have mentioned. 

I dont think you would use it when you already have objects in the OR. You would use description object, when you want to identify and work on objects at run time, generally the objects not in OR. Example, a list that is not getting identified as a list, and then all the dropdown options of that list are webelements ( we cant add all options of a drop down list to the OR) so in such cases, you would use description object to identify the options of the drop down list at run time and select or work on it.

If you want to see what objects are getting identified, you can just add a highlight step as shown below to see the object that it is working on and also see the innertext at runtime. 

Set objX = Browser("B").Page("P").ChildObjects(X)

For i=0 to objX.count-1

   objX(i).highlight

   Result = objX(i).GetRPProperty("innertext")

Next

Hope this helps.

View solution in original post

Highlighted
Super Contributor.
Super Contributor.

Thank you!

Maybe your explanation can be added to the UFT Manual?

I will apply the objX(i).highlight  and learn.

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Hi.

A follow up question...

Regarding the "micclass" property. It refers to the "Class" identification property that we see in the obj rep.

However there are sometimes an additional "Class Name" property for specific objects.

Anyone know what the difference between these "classes" is??

 

Thanks!

 

Highlighted
Micro Focus Expert
Micro Focus Expert

hi, 

Can you give an example which has Class Name property, of what technology? To my understanding, Class Name is equivalent to micclass which are both UFT defined class name. 

Thanks.

James

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

hi, 

adding more information here. the script using childobject with a Description object actually returns a collection. Thus the use objX(0) which is the first object in the list meeting the description. You may check the documentation below.

https://admhelp.microfocus.com/uft/en/14.03/UFT_Help/Subsystems/FunctionReference/Subsystems/OMRHelp/OMRHelp.htm#Common_Methods_and_Properties/Common_Methods_and_Properties.html#ChildObjects

Thanks.

James

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.