Hi, I'm testing an application that contains a TreeView with Checkboxes.
The RanorexSpy tool tells me that my Control is a TreeView. The Element section in the tool says that I have a CheckButton (role).
My problem comes when I try to check that checkbox, it doesn't do it. There is no default action associated with it that can let me check the button.
Any ideas?
TreeView with Checkboxes
I would suggest the following:
Select the element with MouseClickElement and then do the same what you normally do in the application if you set the checkbox.
Use the ControlSendKeys() function for keyboard events and the MouseClick() functions for mouse events.
Send us a sample application with the treeview if it doesn't work.
Jenö Herget
Ranorex Team
Select the element with MouseClickElement and then do the same what you normally do in the application if you set the checkbox.
Use the ControlSendKeys() function for keyboard events and the MouseClick() functions for mouse events.
Send us a sample application with the treeview if it doesn't work.
Jenö Herget
Ranorex Team
I tried what you said and it didn't work for me. I think I know why. I am doing the following to trigger the check:
Note that I have used item[0]. From what I understood, the first element of the element tuple was the handle to that element. When I put the numerical value of the handle, as given by Ranorex Spy, it works.
Am I wrong in assuming that the first tuple element is a handle? Because I noted that when I printed that value (item[0]), it gave me a 6 digit number that could not be found by RanorexSpy.
Code: Select all
element = Ranorex.ControlGetElement(hAppWindow);
item = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_CHECKBUTTON, 'element 1');
Ranorex.ControlSendKeys(item[0], ' ');
Code: Select all
element = Ranorex.ControlGetElement(hAppWindow);
item = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_CHECKBUTTON, 'element 1');
Ranorex.ControlSendKeys(1444948, ' ');
You don't need to use the tuple element (item[0]). It's better to find first the tree view control in the application with the FormFindChild functions and then the element in the tree view control with ElementFindChild.
An application can have hundreds of elements but normally only few controls.
The ElementTest.py sample demonstrates this way with a checked list box:
Can it happen that you have two controls with an 'element 1' in it?
Jenö Herget
Ranorex Team
An application can have hundreds of elements but normally only few controls.
The ElementTest.py sample demonstrates this way with a checked list box:
Code: Select all
// Find the checked listbox control in the application
checkedListBox=Ranorex.FormFindChildControlName(hAppWindow,'checkedListBox1')
if checkedListBox == 0:
print 'ERROR: checkedListBox not found'
return 1
print ' moving the mouse to the control'
Ranorex.MouseMoveToControl(checkedListBox)
print ' searching the element Item2 in the checkedListBox'
element=Ranorex.ControlGetElement(checkedListBox)
item2 = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_CHECKBUTTON, 'Item2')
if item2 == None:
print 'ERROR: Item2 not found'
return 1
print ' moving the mouse to item2 and selecting it'
Ranorex.MouseClickElement(item2)
print ' calling the default action'
Ranorex.ElementDoDefaultAction(item2)
That's wright, the first tuple element is the handle of the control.tkondal wrote:Am I wrong in assuming that the first tuple element is a handle?
Can it happen that you have two controls with an 'element 1' in it?
Jenö Herget
Ranorex Team
Hi Jenö,
I figured out the problem after all. Yes, the handle that I got was in fact correct. The problem was that the ControlSendkeys() was not captured by the parent control. The parent control was responsible of treating keys not the actual child that I was targeting.
So, to fix the problem, I selected my treeView element as before, but this time, I sent the ControlSendKeys to the treeView, not the treeView element.
This is why, we need a capture-replay tool fast Any chance of providing a beta or something, soon?
Thanks.
I figured out the problem after all. Yes, the handle that I got was in fact correct. The problem was that the ControlSendkeys() was not captured by the parent control. The parent control was responsible of treating keys not the actual child that I was targeting.
So, to fix the problem, I selected my treeView element as before, but this time, I sent the ControlSendKeys to the treeView, not the treeView element.
This is why, we need a capture-replay tool fast Any chance of providing a beta or something, soon?
Thanks.