Read state of checkbox

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
dareim
Posts: 9
Joined: Tue Apr 22, 2008 8:19 am

Read state of checkbox

Post by dareim » Mon Dec 15, 2008 9:13 am

Hello all

I can't find a way to get the state of a checkbox (checked or not checked).
WebElement.Value is always "on".

My code:
ACADoc = WebDocument.OpenDocument(url, true, 30000);
WebElement e = ACADoc.FindSingle(CheckBoxId);
e.?


Thanks for helping,
Daniel

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

Post by Support Team » Mon Dec 15, 2008 10:53 am

Get the value of the "Checked" attribute, it should return the string "True" if the checkbox is checked:

Code: Select all

string checkedString = e.GetAttribute(Attributes.Checked);
Regards,
Alex
Ranorex Support Team
Last edited by Support Team on Tue Dec 16, 2008 10:02 am, edited 1 time in total.

dareim
Posts: 9
Joined: Tue Apr 22, 2008 8:19 am

Post by dareim » Mon Dec 15, 2008 11:52 am

Hi Alex

I don't know what I'm doing wrong - but my checkedString variable stays null, when I try the code from you.
There is no difference, if the checkbox is checked or not.

Regards,
Daniel

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

Post by Support Team » Tue Dec 16, 2008 9:45 am

That sounds like a bug we fixed in the latest Ranorex 1.5 update (V1.5.1.5004). Please download the latest version and try again with the update DLLs!

Regards,
Alex
Ranorex Support Team

dareim
Posts: 9
Joined: Tue Apr 22, 2008 8:19 am

Post by dareim » Tue Dec 16, 2008 10:53 am

Yes, V1.5.1 works!
Thanks for the help.

Is there an overview of the parameters for the method GetAttribute(..) ?

Kind regards,
Daniel

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

Post by Support Team » Tue Dec 16, 2008 12:12 pm

The attribute names are listed in the Ranorex.Web.Attributes class. Just use any of the fields as parameter to the WebElement.GetAttribute method as in the example I posted above.

Regards,
Alex
Ranorex Support Team