Page 1 of 1

Get property values from controls

Posted: Tue Feb 04, 2014 2:50 pm
by Japise
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

Re: Get property values from controls

Posted: Tue Feb 04, 2014 4:10 pm
by Support Team
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
Regards,
Robert

Re: Get property values from controls

Posted: Tue Feb 04, 2014 4:53 pm
by Japise
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

Re: Get property values from controls

Posted: Tue Feb 04, 2014 8:15 pm
by KurtZ
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

Re: Get property values from controls

Posted: Wed Feb 05, 2014 9:01 am
by Japise
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

Re: Get property values from controls

Posted: Thu Jul 24, 2014 11:34 am
by AutomationTester
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