Validating Size attribute

Ask general questions here.
Warun
Posts: 4
Joined: Thu Oct 11, 2012 10:19 am

Validating Size attribute

Post by Warun » Mon Oct 15, 2012 11:59 am

Hi,

I am using ranorex to validate sizes of UI elements such as buttons etc. But

ValidateAnyAttributeValueOfAutomationElement(
string path,
string attrName,
object expectedValue,
string message = "",
bool exceptionOnFail = false)

is throwing an error when we pass the following "expected value" argument: new System.Drawing.Size(width, height)
Please let me know how i can validate sizes of UI elements.

Thanks in advance!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Validating Size attribute

Post by Support Team » Tue Oct 16, 2012 3:45 pm

Hi,

Which Ranorex method are you using in order to get the size of your element?

Regards,
Markus
Ranorex Support Team

Warun
Posts: 4
Joined: Thu Oct 11, 2012 10:19 am

Re: Validating Size attribute

Post by Warun » Mon Oct 22, 2012 8:35 am

The size of the button was constant. So, I just instantiated a new system.drawing.size object with those constant width and height values and passed it to the ranorex's validate method.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Validating Size attribute

Post by Support Team » Mon Oct 22, 2012 10:54 am

Hi,

The following code should work for you:
var start = repo.Start.Start;
Validate.AreEqual(start.Element.Size, new Size(54, 40));
I used the Windows start button for test purposes and this worked as expected on my machine.

Regards,
Markus
Ranorex Support Team

Warun
Posts: 4
Joined: Thu Oct 11, 2012 10:19 am

Re: Validating Size attribute

Post by Warun » Wed Nov 07, 2012 5:45 am

Thanks a lot! It works!