Checkbox at Element-Level no function

Class library usage, coding and language questions.
jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Checkbox at Element-Level no function

Post by jabelshauser » Wed Jan 14, 2009 3:59 pm

Hi

in a exceed-gridcontrol-cell is placed a Checkbox. Because of the exceed-cell, i have lost the control-level and have to work at element-level.

Problem:
If i try to activate the checkbox using "DoDefaultAction", nothing happens.

--> Only in Debug-Mode, when i place a breakpoint at the line where DoDefaultAction will be executed (and change the focus to visual studio ?) the checkbox will be activated.

Has everyone any idea ?

regards and thanks
Jörg

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Thu Jan 15, 2009 10:58 am

This could be a focus problem. Try to focus the element:

Code: Select all

element.Select(Selection.TakeFocus);
If that does not work, try focusing the control first:

Code: Select all

Control control = element.Control;
control.Focus();
element.Select(Selection.TakeFocus);
Regards,
Alex
Ranorex Support Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Fri Jan 16, 2009 11:21 am

both proposals doesn't help.
btw: other elements e.g. a Text-Element which is placed at same level (inside a exceed-cell) can be written successfull, only the checkbox doesn't work.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Fri Jan 16, 2009 1:05 pm

If checking the CheckBox using DoDefaultAction works when you place a breakpoint in Studio, this should be a focus or timing problem.

Could you please insert a Sleep statement before executing DoDefaultAction:

Code: Select all

System.Threading.Thread.Sleep(1000); // milliseconds
element.DoDefaultAction();
The other thing that comes to my mind is checking that the application with the checkbox is active. Please, try to use Form.Activate on your application form before executing DoDefaultAction.

Regards,
Alex
Ranorex Support Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Mon Jan 19, 2009 8:46 am

not a timing, but a (inverted ?) Focus-Problem. This works (but not practicable):

Application.FindFormTitle("Microsoft Visual C#",SearchMatchMode.MatchSubstring).Activate();

dc.Checked = true; //dc is a checkbox in "form"
form.Activate();

The checkbox is only activated, when i remove the the focus from the test-form to another form before i activate the checkbox. works also with change to other forms. This is why it works when setting a breakpoint at the "dc.Checked = true" line.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Mon Jan 19, 2009 6:14 pm

This is really some weird behavior. Seems like the control manufacturer did not properly implement the MSAA DoDefaultAction for that control.

Sorry, but you will need to use that workaround, i.e. activating some other window. Maybe focussing another control in your application under test works, too, so you don't have a dependency on another application.

Regards,
Alex
Ranorex Support Team

jabelshauser
Posts: 55
Joined: Thu Aug 23, 2007 12:00 pm

Post by jabelshauser » Tue Jan 20, 2009 8:05 am

with ACCExplorer, i can successful execute DoDefaultAction. There must be a difference to Ranorex.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Tue Jan 20, 2009 9:32 am

If you execute DoDefaultAction with AccExplorer, the focus is on the AccExplorer application, not on your application under test (AUT). And the problem is that DoDefaultAction does not work when the focus is on the AUT. So, I don't see any advantage in using AccExplorer ...

I had a look on the source code of the Element.DoDefaultAction method and it does nothing but calling the MSAA DoDefaultAction interface function.

Why don't you use the Mouse to click on the checkbox instead of using the Element.DoDefaultAction method? Clicking with the mouse is the most realistic way, DoDefaultAction heavily depends on the MSAA implementation of the control.

Regards,
Alex
Ranorex Support Team