TreeItem Label Text

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
zshadow
Posts: 28
Joined: Sat Aug 30, 2014 5:17 pm

TreeItem Label Text

Post by zshadow » Sat Oct 18, 2014 4:18 pm

Hi,

I want to read the name(label) of the treeitem, the items do not have the 'Text' attribute set.
I have attached a screen shot of the tree showing the treeitems eg I want to get the text "204-00 Suspension system (140)" when I click on it, is there any of getting that text, also the tree is in a NativeWindow
My Code is :

public void Mouse_DoubleClick_Tree338()
{
TreeItem SignalsTree = "/dom[@domain='localhost:8080']//object[#'Tabman']//element[@instance='1']/element[@instance='0']//tree[@controlid='338']/treeitem[2]";
SignalsTree.Click();
foreach (Ranorex.TreeItem item in SignalsTree.Items)
{
item.Expand();
item.Click();
//string itemName = item.Text;

Report.Info("item.Text);
IterateTree(item);

}
}

static void IterateTree(Ranorex.TreeItem treeItem)
{
foreach (Ranorex.TreeItem item in treeItem.Items)
{
item.Click();

Report.Info(item.Text.ToString());

}
}
Attachments
ranspy.png
ranspy.png (107.72 KiB) Viewed 1916 times
WidgetSetWndClass_Screenshot.png
Image of the treeItems
WidgetSetWndClass_Screenshot.png (18.69 KiB) Viewed 1916 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: TreeItem Label Text

Post by odklizec » Sun Oct 19, 2014 10:29 am

Hi,

If the tree element texts cannot be found anywhere in the Ranorex spy, then I'm afraid, your only hope are RawTexts. To be able to read the RawTexts, you need to add the SysTreeView32 class to the GDI capture list. See this tutorial how to extend the GDI capture list... http://www.ranorex.com/support/user-gui ... tions.html
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

zshadow
Posts: 28
Joined: Sat Aug 30, 2014 5:17 pm

Re: TreeItem Label Text

Post by zshadow » Sun Oct 19, 2014 4:41 pm

Hi,

Thanks for your reply, but I don't see the option to add class name to GDI Capture list when I right click on the items, is there a setting I need to activate ?

Regards

zshadow

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: TreeItem Label Text

Post by odklizec » Sun Oct 19, 2014 5:34 pm

Try right click the tree root element (not the individual tree items). Tree '338' as from your screenshot.I believe it's also possible to add the class name manually? Just enter SysTreeView32 to the GDI Capture list. Then restart/refresh Spy to see the effect.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

zshadow
Posts: 28
Joined: Sat Aug 30, 2014 5:17 pm

Re: TreeItem Label Text

Post by zshadow » Sun Oct 19, 2014 6:26 pm

Hi,

I had to use the option "Add to Repository (incl. Children)" to add the tree Items I am not sure if that's the correct way to do it?

Regards

zshadow

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3914
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: TreeItem Label Text

Post by odklizec » Sun Oct 19, 2014 7:40 pm

Hi,

No, this is not it. You need to use "add class name to GDI capture list".
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

zshadow
Posts: 28
Joined: Sat Aug 30, 2014 5:17 pm

Re: TreeItem Label Text

Post by zshadow » Mon Oct 20, 2014 7:22 pm

Hi,

I did what you suggested, now I want to match a variable string against of the rawtext items, as some of them are not visible, how would you check for their existence ? I tried the code but doesn't find the element. Is there any way of finding the rawtext when it is not visible?

Code: Select all

Button dBtn = "/dom[@domain='localhost:8080']//object[#'Tabman']//element[@instance='1']/element
[@instance='0']//tree[@controlid='338']/scrollbar[@style='Vertical']/button[@text='Down']";
    Delay.Milliseconds(500);    
       
         Button dBtn = "/dom[@domain='localhost:8080']//object[#'Tabman']//element[@instance='1']/element

[@instance='0']//tree[@controlid='338']/scrollbar[@style='Vertical']/button[@text='Down']";
    Delay.Milliseconds(500);    
       
   RawText rrtxt1 = "/dom[@domain='localhost:8080']//object[#'Tabman']//element[@class='481D9404-6E8D-4c7c-ACC7-

63DDC8D5F555']/element[@instance='1']/element[@instance='0']//tree[@controlid='338']/rawtext[@rawtext='+var_string+']";
   
         do {
         	Report.Info("not visible");
         	dBtn.Click();
         } while (!rrtxt1.Visible);
              
        Report.Info("RowText = "+rrtxt1.ToString());
        rrtxt1.DoubleClick();
Also I was wondering if I could get the rawtext by doing something like this :

Code: Select all

TreeItem SignalsTree = "/dom[@domain='localhost:8080']//object[#'Tabman']//element[@instance='1']/element[@instance='0']//tree[@controlid='338']/treeitem[2]";
        	SignalsTree.Click();

        foreach (Ranorex.TreeItem item in SignalsTree.Items)
        {
       		Report.Info("text = "+item.GetType().GetProperty("Text").GetValue(item, null).ToString());	
        }
Thanks

zshadow

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TreeItem Label Text

Post by Support Team » Wed Oct 22, 2014 10:09 am

Hello zshadow,

Unfortunately, it is not possible to check the visibility of a rawtext element since the item cannot be identified if it’s invisible. The graphical user interface (GDI) is used for drawing elements on the screen. If the specific element is not visible (not drawn) Ranorex cannot recognize the element via the GDI Plug-In . Maybe an image-based approach could solve your issue.

Regards,
Robert
.
Image

zshadow
Posts: 28
Joined: Sat Aug 30, 2014 5:17 pm

Re: TreeItem Label Text

Post by zshadow » Wed Oct 22, 2014 7:49 pm

Hi Robert,

Is it possible to convert the tree items below to be converted to images some how and validate ag
ainst a string depicted in the image, using the image method as stated in the TreeItem Class shown below?

Or any other way?

Image The image or icon associated with the tree item.
http://www.ranorex.com/Documentation/R ... eeItem.htm

Code: Select all

TreeItem SignalsTree = "/dom[@domain='localhost:8080']//object[#'Tabman']//element[@instance='1']/element[@instance='0']//tree[@c[b][/b]ontrolid='338']/treeitem[2]";
SignalsTree.Click();
foreach (Ranorex.TreeItem item in SignalsTree.Items)
{
item.Expand();
item.Click();
//string itemName = item.Text;

Report.Info("item.Text);
IterateTree(item);

}
Regards

Navin

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: TreeItem Label Text

Post by Support Team » Thu Oct 30, 2014 2:55 pm

Hello,

As already discussed via email:

The suggested imaged based recording/validation will only work with images. So, you cannot compare the images from a tree item with a string value.

Regards,
Robert
.
Image