Get property values from controls

Ranorex Spy, Recorder, and Studio.
Japise
Posts: 5
Joined: Wed Jan 15, 2014 4:13 pm

Get property values from controls

Post by Japise » Tue Feb 04, 2014 2:50 pm

Hi,

Been trying to get the 'Widht'-property from a object inheriting from a System.Windows.Forms.Control using the GetValue action in the recorder, but it just returns null?

Can this be achieved or do we need to write user methods for retrieving such properties? Examples?

/Best reards
Jari

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

Re: Get property values from controls

Post by Support Team » Tue Feb 04, 2014 4:10 pm

Hi Japise,

Normally it should not be a problem to access this property. From which object to you retrieve the “Width”-property? Please check your object. Maybe the value of the property is zero?

If have created a small sample where I retrieve the width of a “CheckBox”. Stored the value in a variable and logged it to the Report.

GetWidthProperty.png
GetWidthProperty.png (123.94 KiB) Viewed 2425 times
Regards,
Robert
.
Image

Japise
Posts: 5
Joined: Wed Jan 15, 2014 4:13 pm

Re: Get property values from controls

Post by Japise » Tue Feb 04, 2014 4:53 pm

I'm trying to fetch the value from a column header (Thirdparty grid called flexgrid). The value I'm interested in is the Size property found in the detail tab. Getting null when trying to reference it in the GetValue method Assumed it was a control based on the properties in the detail section.

/J
Attachments
Example.png
Example.png (33.09 KiB) Viewed 2422 times

KurtZ
Posts: 12
Joined: Fri Jul 12, 2013 2:24 pm

Re: Get property values from controls

Post by KurtZ » Tue Feb 04, 2014 8:15 pm

I think you are getting null because "Size" as you have highlighted in your screen print is just redisplaying the width and height properties. If you switch to the Overview tab, you will probably see the Size property is blank.

You need to get the Width and Height directly as Robert shows in his screen print. You can also modify your code with something like:

Code: Select all

Cell.Element.GetAttributeValue("width")
or

Code: Select all

Cell.Element.Size.Width

Japise
Posts: 5
Joined: Wed Jan 15, 2014 4:13 pm

Re: Get property values from controls

Post by Japise » Wed Feb 05, 2014 9:01 am

Thanks for the quick response! I tried the code and it seems that there's only the size property available in the class, since running:

Code: Select all

Cell.Element.GetAttributeValue("width")
returns null, while

Code: Select all

Cell.Element.Size.Width
returns the value.

I would guess that there is no support for accessing sub-properties by using the GetValue action (like "Size.Width")?. So this needs to be made a user method in this case.

/J

AutomationTester
Posts: 30
Joined: Mon Jan 21, 2013 1:31 pm

Re: Get property values from controls

Post by AutomationTester » Thu Jul 24, 2014 11:34 am

Hai Japise,

You should use

Code: Select all

Cell.Element.GetAttributeValueText("width")
instead of Cell.Element.GetAttributeValue("width") to get the width.

GetAttributeValueText will retrieve the value of the attribute specified in the quotes.

Regards,
Amiruddin, Indium software - Automation COE