Focus lost for nested dialogs

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Focus lost for nested dialogs

Postby hoshang.varshney » Tue Mar 01, 2011 12:14 am

Q. Why is my test throwing WidgetNotFoundException when a nested dialog is closed?

A. When a button is clicked within the first dialog it opens another dialog. After closing the second dialog, the test stops and throws a WidgetNotFoundException. This happens because the first dialog does not get the focus back. Make sure when the second dialog is closed the focus goes back to the first dialog.


The above paragraph i got from FAQs. I am encountering the same problem. I want to know the solution.
I have tried to manually insert the code to bring focus to 1st dialog by clicking on the it after the 2nd dialog is closed. But still i get the same exception.

Please help! Thanks!
hoshang.varshney
 
Posts: 10
Joined: Tue Feb 15, 2011 4:56 am

Re: Focus lost for nested dialogs

Postby gnebling » Tue Mar 01, 2011 5:05 pm

How are you setting the focus? Have you tried this... (replace Workbench... with your window).
Code: Select all
ui.ensureThat(new WorkbenchLocator().hasFocus());
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Re: Focus lost for nested dialogs

Postby hoshang.varshney » Tue Mar 01, 2011 10:06 pm

Yes, I have used ui.ensureThat(new ShellLocator("").hasFocus());
For me, 1st dialog and 2nd dialog have same title i.e. "null" no title. Still the focus is set to the eclipse workspace after the 2nd dialog is disposed

ui.click(new ButtonLocator("&Add Service...")); // this button opens 2nd dialog
ui.wait(new ShellShowingCondition("")); // this is 2nd dialog

ui.click(1, new TableItemLocator(""), WT.CHECK); // checkbox is checked on 2nd dialog

ui.click(new ButtonLocator("OK")); // OK button of 2nd dialog

ui.ensureThat(new ShellLocator("").hasFocus()); // to ensure focus for 1st dialog(both 1st and 2nd dialogs have no title)
ui.click(new SWTWidgetLocator(Composite.class, new LabeledLocator(
Composite.class, "&Client Configurations:"))); // Client Configuration is a label on 1st dialog
hoshang.varshney
 
Posts: 10
Joined: Tue Feb 15, 2011 4:56 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest

cron