can't access specific property of repository element in code

Ask general questions here.
hnporter
Posts: 18
Joined: Thu Jan 16, 2014 3:34 pm

can't access specific property of repository element in code

Post by hnporter » Thu Jan 16, 2014 6:05 pm

Hi, the app that I'm looking to automate basically uses cells to render its data. It looks something like this, and I've added an arrow to show the element I'm interested in:

Image

The first thing I've done is a Validate on that element (during a Record), which is then compared to a separate variable. If the values match, it passes. The line for the validation (auto-generated by Ranorex) is:

Validate.Attribute(repo.TaxUseMockUp.topCellUAPInfo, "UIAutomationValueValue", varTaxAllocValue);

where topCellUAPInfo is the element name, UIAutomationValueValue is the property, and varTaxAllocValue is the variable. If I look at the repository item in Spy, I see the property here:

Image

However, I want to directly access that value and work with it. But if I try to directly drill down into it via the code (i.e. repo.TaxUseMockUp.topCellUAP.etc.) I can't locate the value. Obviously, the property is accessible - Ranorex can validate off of it, and I can see it in Spy. Can anyone offer insight on how to drill into it using code? Thanks!

hnporter
Posts: 18
Joined: Thu Jan 16, 2014 3:34 pm

Re: can't access specific property of repository element in code

Post by hnporter » Fri Jan 17, 2014 5:38 pm

Never mind...I finally figured out to use Element to drill down into that property (i.e. repo.MyApp.MyRepoItem.Element.GetAttributeValueText("MyValue").

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: can't access specific property of repository element in code

Post by Support Team » Fri Jan 17, 2014 10:38 pm

The recommended way is to use the right Ranorex adapter, then you don't need to specify the attribute value as a string. The right adapter is shown in Ranorex Spy, in your example UIAutomationValue, like explained in the following Ranorex User Guide chapter:
http://www.ranorex.com/support/user-gui ... apter.html

For your example, the code would look like the following:
string value = repo.TaxUseMockUp.topCellUAP.As<UIAutomationValue>().Value;
Regards,
Alex
Ranorex Team
.
Image