Page 1 of 1

uiautomationvalue list

Posted: Wed Jul 27, 2016 2:59 pm
by mander95
trying to create a function that filters through a ranorex list till it finds an element with the matching AttributeValue, please help

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 3:16 pm
by odklizec
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.

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 3:28 pm
by asdf
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

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 3:47 pm
by mander95
this is the list in question

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 4:16 pm
by odklizec
Please post SNAPSHOT, not screenshot, thanks! ;)

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 6:48 pm
by mander95
the list in quesiton, the attributs I'm trying to distinguish by is called UIAutomationValueValue

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 7:54 pm
by krstcs
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.

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 8:43 pm
by mander95
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

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 9:43 pm
by krstcs
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

Re: uiautomationvalue list

Posted: Wed Jul 27, 2016 9:44 pm
by mander95
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

Re: uiautomationvalue list

Posted: Thu Jul 28, 2016 3:28 pm
by krstcs
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.

Re: uiautomationvalue list

Posted: Thu Jul 28, 2016 5:17 pm
by mander95
it works, thank you