uiautomationvalue list

Ask general questions here.
mander95
Posts: 66
Joined: Tue Jun 21, 2016 7:35 pm

uiautomationvalue list

Post by mander95 » Wed Jul 27, 2016 2:59 pm

trying to create a function that filters through a ranorex list till it finds an element with the matching AttributeValue, please help

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

Re: uiautomationvalue list

Post by odklizec » Wed Jul 27, 2016 3:16 pm

Hi,

Please upload a Ranorex snapshot (not SCREENSHOT!) of the list in question. There is not much we can suggest without it, except to search for similar posts here at forum. You see, there is simply not enough info in your post.
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

asdf
Posts: 174
Joined: Mon Mar 21, 2016 3:16 pm

Re: uiautomationvalue list

Post by asdf » Wed Jul 27, 2016 3:28 pm

Hi mander,

In order to achieve your intention, i would recommend using the following code.

Code: Select all

var list = Host.Local.Find<LiTag>(@"/dom[@caption='Lists.html']/?/?/ul/li");
foreach(var item in list)
{
     var val = item.Element.GetAttributeValue("Innertext");
     if(val.ToString() == "ValueOfTheAttribute")
     {
          Report.Success("Attribute was found in list");
          break;
     }
        		
}
        	
I hope this helps.

Kind regards,
asdf

mander95
Posts: 66
Joined: Tue Jun 21, 2016 7:35 pm

Re: uiautomationvalue list

Post by mander95 » Wed Jul 27, 2016 3:47 pm

this is the list in question
Attachments
PatientFileListScreenshot.jpg
list
PatientFileListScreenshot.jpg (36.9 KiB) Viewed 579 times

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

Re: uiautomationvalue list

Post by odklizec » Wed Jul 27, 2016 4:16 pm

Please post SNAPSHOT, not screenshot, thanks! ;)
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

mander95
Posts: 66
Joined: Tue Jun 21, 2016 7:35 pm

Re: uiautomationvalue list

Post by mander95 » Wed Jul 27, 2016 6:48 pm

the list in quesiton, the attributs I'm trying to distinguish by is called UIAutomationValueValue
Attachments
listSnapshot.rxsnp
(322.78 KiB) Downloaded 28 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: uiautomationvalue list

Post by krstcs » Wed Jul 27, 2016 7:54 pm

Without a LOT more information, this is still very hard to help with.

What is your goal?
What "attribute" are you trying to find?
What part of the element contains the "attribute"?
Is the "attribute" in a sub-element?
What VALUE is the "attribute" you are looking for?
Have you looked at the snapshot and gone through a ListItem element all the way down until you found the "attribute"?

Please ALWAYS give as much information as possible so that we don't have to continually ask for more. This will greatly speed up the process and allow us to understand the exact nature of the request more quickly.

RanoreXPath is basically a notation for describing a tree structure. Ranorex Spy (and hence the snapshot) displays all UI elements in a tree. If you don't tell us what part of the tree you are talking about, we can't help. And if you figure it out by looking, then it helps you.
Shortcuts usually aren't...

mander95
Posts: 66
Joined: Tue Jun 21, 2016 7:35 pm

Re: uiautomationvalue list

Post by mander95 » Wed Jul 27, 2016 8:43 pm

My goal is to be able to make a function that will take in a string that is intended to match the specified attribute in the list.

From the list I sent in the snapshot, each item is of type Ranorex.Text and has a unique identifier called UIAutomationValueValue.

The function should run through the list of Ranorex.Text items and look at each of their UIAutomationValueValues and if the UIAutomationValueValue for that item matches the input string, then click it and break the loop.

If you use the GetAttributeValueText value on the individual repository items, it can be identified.

For example:
Report.Log(Reportleve.Info,"info", repo.SystemItemNameDisplay.Element.GetAttributeValueText("UIAutomationValueValue"));

outputs "mast 03 sim.0.tom" which is what can observed in the view spy under this specific attribute

I think that UIAutomationValueValue is a sub element

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: uiautomationvalue list

Post by krstcs » Wed Jul 27, 2016 9:43 pm

Well, each ListItem ALSO has that same attribute, and it contains the information you are looking for.

If you just want to click on the ListItem with that value in it, you will need to parameterize your XPath like this:

/listitem[@UIAutomationValueValue=$myValue]

myValue will be a repository variable.

You will then need to bind the variable when used in a module to the data needed.

There is no need to create a special function/method for this. Ranorex will handle it all in the background.

You can read about all of this in the user guide, which I highly recommend you read: http://www.ranorex.com/support/user-guide-20.html
Shortcuts usually aren't...

mander95
Posts: 66
Joined: Tue Jun 21, 2016 7:35 pm

Re: uiautomationvalue list

Post by mander95 » Wed Jul 27, 2016 9:44 pm

this is the snapshot of the list item itself

I still want to be able to make the function adjustable. The string in the input parameter is what i'm trying to match to the UIAutomationValueValue. So if I change the string, it should be able to find another item in the list. Basically, I want to be able to loop through the list to find the item with that matching parameter and click it for any input string so long as the UIAutomationValueValue exists in that list
Attachments
listItemSnapshot.rxsnp
(158.8 KiB) Downloaded 26 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: uiautomationvalue list

Post by krstcs » Thu Jul 28, 2016 3:28 pm

My post outlined how to do what you are wanting without you having to write any code. Please, read it again, as well as the user guide. Adding the variable ($myValue) to the RanoreXPath of the element in your Repository makes the path variable, as you requested, depending on what value you pass to the 'myValue' parameter in your recording module.

Your goal is handled very easily by Ranorex.

What you are asking for does what Ranorex already does for you, but at a higher cost - namely that you have to write code, and your code will take longer to do what you want than Ranorex would if you did it the way I suggested.
Shortcuts usually aren't...

mander95
Posts: 66
Joined: Tue Jun 21, 2016 7:35 pm

Re: uiautomationvalue list

Post by mander95 » Thu Jul 28, 2016 5:17 pm

it works, thank you