Can't get accesibleValue while iterating through list of treeitems.

Class library usage, coding and language questions.
Zygmuntt
Posts: 1
Joined: Fri Feb 22, 2019 3:30 pm

Can't get accesibleValue while iterating through list of treeitems.

Post by Zygmuntt » Fri Feb 22, 2019 3:39 pm

Hello, got a pretty big problem.
I've got an list with dynamicly generting objecets (treeitems).
I have to find all of them, and then get their value, which according to ranorex Spy is stored in AccessibleValue.
I'm able to get all of those items, but can't get AccessibleValue, for me it's always null.
Here's my code:
void ITestModule.Run()

Code: Select all

        {
           IList<TreeItem> h2List = Zliaczanie_pracownikowRepository.Instance.FrmMain.DataPanel.Self.Find<TreeItem>(".//TreeItem");
            foreach (Ranorex.TreeItem h2item in h2List) 
            {

            	h2item.MoveTo();
            var value =	h2item.GetAttributeValue<TreeItem>("AccessibleValue");  	 
        	}
        }
Move to was just to check, if its really this element, and it is. It can move to it without any problem, but cant get this Accessible Value.
Any ideas how to fix it?
Attachments
ranorex_repo.png
ranorex_repo.png (63.38 KiB) Viewed 289 times

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

Re: Can't get accesibleValue while iterating through list of treeitems.

Post by odklizec » Mon Feb 25, 2019 8:37 am

Hi,

Please upload a Ranorex snapshot (NOT screenshot) of the problematic element. Screenshot is not very helpful. Additionally, try to add 'Element' and use 'GetAttributeValueText' method in your code, like this:

Code: Select all

            var value =	h2item.Element.GetAttributeValueText<TreeItem>("AccessibleValue");
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

manish
Posts: 46
Joined: Fri Aug 10, 2018 12:46 pm

Re: Can't get accesibleValue while iterating through list of treeitems.

Post by manish » Thu Mar 07, 2019 3:09 pm

Hi,

The attribute value that you want to get is a string, I guess, so try changing

Code: Select all

var value =	h2item.GetAttributeValue<TreeItem>("AccessibleValue");
to

Code: Select all

var value =	h2item.GetAttributeValue<string>("AccessibleValue");
Hope it helps :)
Manish