TreeView with Checkboxes

Class library usage, coding and language questions.
tkondal
Posts: 24
Joined: Fri Nov 03, 2006 5:50 pm

TreeView with Checkboxes

Post by tkondal » Thu Nov 09, 2006 5:57 pm

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?

tkondal
Posts: 24
Joined: Fri Nov 03, 2006 5:50 pm

Post by tkondal » Thu Nov 09, 2006 7:04 pm

I forgot to mention that I have tried sending mouse clicks and button checks. These only select the item in the treeview, they don't set the check.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Thu Nov 09, 2006 9:25 pm

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

tkondal
Posts: 24
Joined: Fri Nov 03, 2006 5:50 pm

Post by tkondal » Mon Nov 13, 2006 2:46 pm

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:

Code: Select all

element = Ranorex.ControlGetElement(hAppWindow);
item = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_CHECKBUTTON, 'element 1');
Ranorex.ControlSendKeys(item[0], ' ');
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.

Code: Select all

element = Ranorex.ControlGetElement(hAppWindow);
item = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_CHECKBUTTON, 'element 1');

Ranorex.ControlSendKeys(1444948, ' ');
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.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Mon Nov 13, 2006 10:32 pm

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:

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)
tkondal wrote:Am I wrong in assuming that the first tuple element is a handle?
That's wright, the first tuple element is the handle of the control.
Can it happen that you have two controls with an 'element 1' in it?

Jenö Herget
Ranorex Team

tkondal
Posts: 24
Joined: Fri Nov 03, 2006 5:50 pm

Post by tkondal » Tue Nov 14, 2006 2:15 pm

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.

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Tue Nov 14, 2006 10:21 pm

tkondal wrote:This is why, we need a capture-replay tool fast. Any chance of providing a beta or something, soon?
I'm sorry, but i think we will have the first beta only next year.

Jenö Herget
Ranorex Team