Trouble changing the state of an infragistics checkbox

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
ranoman
Posts: 26
Joined: Mon Jul 26, 2010 6:59 pm

Trouble changing the state of an infragistics checkbox

Post by ranoman » Mon Jul 26, 2010 7:03 pm

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

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Trouble changing the state of an infragistics checkbox

Post by Ciege » Mon Jul 26, 2010 7:52 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

ranoman
Posts: 26
Joined: Mon Jul 26, 2010 6:59 pm

Re: Trouble changing the state of an infragistics checkbox

Post by ranoman » Mon Jul 26, 2010 8:26 pm

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!
You do not have the required permissions to view the files attached to this post.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Trouble changing the state of an infragistics checkbox

Post by Ciege » Mon Jul 26, 2010 8:43 pm

try mycheckbox.click(Location.CenterLeft) or do a double click.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

ranoman
Posts: 26
Joined: Mon Jul 26, 2010 6:59 pm

Re: Trouble changing the state of an infragistics checkbox

Post by ranoman » Mon Jul 26, 2010 9:51 pm

Tried both....Still does not click on the checkbox....

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Trouble changing the state of an infragistics checkbox

Post by Ciege » Mon Jul 26, 2010 10:11 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

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

Re: Trouble changing the state of an infragistics checkbox

Post by Support Team » Tue Jul 27, 2010 8:36 am

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

ranoman
Posts: 26
Joined: Mon Jul 26, 2010 6:59 pm

Re: Trouble changing the state of an infragistics checkbox

Post by ranoman » Tue Jul 27, 2010 4:55 pm

Thanks! I have used relative coordinates for now