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
Trouble changing the state of an infragistics checkbox
Re: Trouble changing the state of an infragistics checkbox
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 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...
Ciege...
Re: Trouble changing the state of an infragistics checkbox
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!
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.
Re: Trouble changing the state of an infragistics checkbox
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...
Ciege...
Re: Trouble changing the state of an infragistics checkbox
Tried both....Still does not click on the checkbox....
Re: Trouble changing the state of an infragistics checkbox
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.
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...
Ciege...
- Support Team
- 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
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.
Regards,
Alex
Ranorex Team
... 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.Ciege wrote:This takes just a bit of (simple) coding on your part.
Regards,
Alex
Ranorex Team
Re: Trouble changing the state of an infragistics checkbox
Thanks! I have used relative coordinates for now