Page 1 of 1

TreeItem Label Text

Posted: Sat Oct 18, 2014 4:18 pm
by zshadow
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());

}
}

Re: TreeItem Label Text

Posted: Sun Oct 19, 2014 10:29 am
by odklizec
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?

Re: TreeItem Label Text

Posted: Sun Oct 19, 2014 4:41 pm
by zshadow
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

Re: TreeItem Label Text

Posted: Sun Oct 19, 2014 5:34 pm
by odklizec
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.

Re: TreeItem Label Text

Posted: Sun Oct 19, 2014 6:26 pm
by zshadow
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

Re: TreeItem Label Text

Posted: Sun Oct 19, 2014 7:40 pm
by odklizec
Hi,

No, this is not it. You need to use "add class name to GDI capture list".

Re: TreeItem Label Text

Posted: Mon Oct 20, 2014 7:22 pm
by zshadow
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

Re: TreeItem Label Text

Posted: Wed Oct 22, 2014 10:09 am
by Support Team
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

Re: TreeItem Label Text

Posted: Wed Oct 22, 2014 7:49 pm
by zshadow
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

Re: TreeItem Label Text

Posted: Thu Oct 30, 2014 2:55 pm
by Support Team
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