Page 1 of 1

Read state of checkbox

Posted: Mon Dec 15, 2008 9:13 am
by dareim
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

Posted: Mon Dec 15, 2008 10:53 am
by Support Team
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

Posted: Mon Dec 15, 2008 11:52 am
by dareim
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

Posted: Tue Dec 16, 2008 9:45 am
by Support Team
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

Posted: Tue Dec 16, 2008 10:53 am
by dareim
Yes, V1.5.1 works!
Thanks for the help.

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

Kind regards,
Daniel

Posted: Tue Dec 16, 2008 12:12 pm
by Support Team
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