Page 1 of 1

Trouble changing the state of an infragistics checkbox

Posted: Mon Jul 26, 2010 7:03 pm
by ranoman
I am trying to change the state of my checkbox from unchecked to checked...Note that this is not a regular checkbox but it is a checkbox in an infragistics treeview where every node is a checkbox. Note that RanorexSpy recognizes this as a checkbox though....

Below is how I try to do it. I have tried two ways to do it and both of them return an error:

Technique 1:
Ranorex.CheckBox mycheckbox= repo.FormMain.CatalogForm.CheckBoxFW02218GBNN;
if (!mycheckbox.Checked) mycheckbox.Checked = true

Technique 2
Ranorex.CheckBox mycheckbox= repo.FormMain.CatalogForm.CheckBoxFW02218GBNN;
Accessible accItem= new Accessible(mycheckbox);
accItem.DoDefaultAction();

Below is the error I get:

Ranorex.SetAttributeFailedException: Setting attribute 'checked' failed on element '{CheckBox:FW02218GBNN}'. ---> Ranorex.RanorexException: Could not set CheckState to 'Checked' by performing default action.
at Ranorex.Plugin.MsaaFlavorElement.SetAttributeValue(Element element, String name, Object value)
at Ranorex.Core.Element.SetAttributeValue(String name, Object value)
--- End of inner exception stack trace ---
at Ranorex.Core.Element.SetAttributeValue(String name, Object value)
at Ranorex.CheckBox.set_Checked(Boolean value)

Any help is appreciated

Re: Trouble changing the state of an infragistics checkbox

Posted: Mon Jul 26, 2010 7:52 pm
by Ciege
Instead of setting the checked property, why not just issue a click on the object?

If you already have the object and know it's checked state you can issue a mycheckbox.check(); and physically click the checkbox. By doing it this way you are also more closely simulating how a user would be using your GUI and if the developer happened to put some sort of onclick fire method in the checkbox you will trigger it with the physical click but (usually) not with the property set.

Re: Trouble changing the state of an infragistics checkbox

Posted: Mon Jul 26, 2010 8:26 pm
by ranoman
Ciege,
The problem with saying just mycheckbox.click() is that it clicks the center of the tree item and not the checkbox. See screenshot.png to see what I mean.

In my scenario, it is required to click on the checkbox to actually check it. RanorexSpy identifies the whole row as a checkbox item and when I say mycheckbox.click(), it clicks the center of the item. Please see ranorexspy.png for more info.

Any ideas on how I can actually click on the checkbox?

Thanks!

Re: Trouble changing the state of an infragistics checkbox

Posted: Mon Jul 26, 2010 8:43 pm
by Ciege
try mycheckbox.click(Location.CenterLeft) or do a double click.

Re: Trouble changing the state of an infragistics checkbox

Posted: Mon Jul 26, 2010 9:51 pm
by ranoman
Tried both....Still does not click on the checkbox....

Re: Trouble changing the state of an infragistics checkbox

Posted: Mon Jul 26, 2010 10:11 pm
by Ciege
So when you do a location.centerleft, where does it click?
Does double clicking on the text of the checkbox not check the checkbox?

Another thing you can do is get the x/y location of the checkbox yourself then add some to X and add checkbox.height/2 + Y so that you are forcing to click to occur at a little right and 1/2 the height of your checkbox. This takes just a bit of (simple) coding on your part.

Re: Trouble changing the state of an infragistics checkbox

Posted: Tue Jul 27, 2010 8:36 am
by Support Team
As ciege said, if Ranorex does not recognize the checkbox as a separate element (only the list item as a whole), you need to use relative coordinates with respect to the list item bounds to click on the checkbox.
Ciege wrote:This takes just a bit of (simple) coding on your part.
... or you can simply record the action with Ranorex Recorder and use the code that is generated for that action (see Code Actions). The recorder uses relative coordinates inside the found element to click exactly where you have clicked, i.e. on the check box in this list item.

Regards,
Alex
Ranorex Team

Re: Trouble changing the state of an infragistics checkbox

Posted: Tue Jul 27, 2010 4:55 pm
by ranoman
Thanks! I have used relative coordinates for now