Can not iterate tree items in demo app tree

Ask general questions here.
rastek
Posts: 183
Joined: Wed Aug 06, 2014 12:00 pm

Can not iterate tree items in demo app tree

Post by rastek » Wed Sep 30, 2020 11:31 pm

Hi,

I use demo application and I want to click tree items programmatically , I tried few ways but I can not click on items or nodes.

Since this demo application BY ranorex already known by the community, it should not be hard to click items, and nodes etc. please I need help

foreach (TreeItem item in repo.RxMainFrame.TreTestTreeView.Items)
{
item.Click();
}

Xpath for tree view

//tree[@controlname='treTestTreeView']

or

?/?/tabpage[@controlname='RxTabUIElements']/tree[@controlname='treTestTreeView']


And if I record and click items individually, I get this Xpath


?/?/tabpage[@controlname='RxTabUIElements']/tree[@controlname='treTestTreeView']/?/?/treeitem[@accessiblename>'Ranorex Studio fundamenta']
Last edited by rastek on Thu Oct 01, 2020 8:34 pm, edited 1 time in total.

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

Re: Can not iterate tree items in demo app tree

Post by odklizec » Thu Oct 01, 2020 5:02 am

Hi,

The xpath, usable with for...each, must return all tree items! So it must look like

Code: Select all

?/?/tabpage[@controlname='RxTabUIElements']/tree[@controlname='treTestTreeView']/?/?/treeitem
Additionally, instead of referencing repo element like you do in your code, I would suggest to use this approach...
https://www.ranorex.com/help/latest/han ... oryelement
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

rastek
Posts: 183
Joined: Wed Aug 06, 2014 12:00 pm

Re: Can not iterate tree items in demo app tree

Post by rastek » Thu Oct 01, 2020 8:50 pm

I need to write code that fetchs treeItems in Ranorex Demo application, since this is demo of Ranorex this should be easy.

this code didnt work

IList<Ranorex.Button> buttonList = repo.MyApp.EnabledButtonsInfo.CreateAdapters<Ranorex.Button>();

// Move the mouse pointer to each button of the list
// and add a screenshot for each to the report
foreach (Ranorex.Button button in buttonList )
{
button.MoveTo();
Report.Screenshot(button);
}

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

Re: Can not iterate tree items in demo app tree

Post by odklizec » Thu Oct 01, 2020 9:10 pm

Hi,

Of course, this code will not directly work with tree object. It’s just an example of general approach how to enumerate and process list of elements. You must adapt it first! Replacing Ranorex.Button with Ranorex.TreeItem and using proper repo element should do the trick.
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