UnableToFindActiveShellException

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

UnableToFindActiveShellException

Postby hyshyshys » Fri Mar 20, 2009 5:31 am

Hi,

I'm currently in the process of evaluating Window Tester and I have few issues that I should fix before we take our final decision.

One of the major issue is the following:

After a dialog is opened or closed,I have very often the UnableToFindActiveShellException Exception. I read your forum but didn't find any clue to solve this.

I'm using windowTester 3.7.1 (2009-02-19) with Eclipse 3.4.0 Build id: I20080617-2000

When the test run I didn't move the mouse or didn't click the mouse button, but I remarked that the dialog (or view, or editor) that should have the focus don't

1- If during the execution, at the right instant (!!!), I click on the item that should have the focus, the test continue with success. I didn't find a way to keep the focus.

2- I also try to change the way the item is located by using a different Locator but it didn't work.

3- I also try to add wait condition just before the execution of the locator but it never worked.

4- I also try to add ui.pause operation but it also failed. (However it helps me to click on the window to give the focus)


Here a some examples that cause the problem:

Example1:
Code: Select all
   // Example 1: After a wizard is closed, I switch the view to Project explorer in a group of views
   public void testTest5() throws Exception {
      IUIContext ui = getUI();
      ui.click(new ContributedToolItemLocator("newWizardDropDown"));
      ui.wait(new ShellShowingCondition("New"));
      ui.click(new FilteredTreeItemLocator("LiveLab Project"));
      ui.click(new ButtonLocator("&Next >"));
      ui.enterText("Project1");
      ui.click(new ButtonLocator("&Finish"));
      ui.wait(new ShellDisposedCondition("New LiveLab Project"));
         
      //------------------------ Next Line will failed ------------------
      ui.click(new CTabItemLocator("Project Explorer"));
      ...
   }


Example 2
Code: Select all
   // Example 2: I open the preferences and then try to click an item of one of my page
   public void testTest4() throws Exception {
      IUIContext ui = getUI();
      ui.click(new MenuItemLocator("Window/Preferences"));
      ui.wait(new ShellShowingCondition("Preferences"));
      ui.click(new FilteredTreeItemLocator("LiveLab/Directories"));
      //------------------------ Next Line will failed ------------------
      ui.click(new NamedWidgetLocator("emtpInstallationFolderText"));
   }



Here is the traceback of the first example
Code: Select all
com.windowtester.runtime.swt.finder.UnableToFindActiveShellException
   at com.windowtester.finder.swt.WidgetFinderService.collectMatchesIn(WidgetFinderService.java:81)
   at com.windowtester.finder.swt.WidgetFinderService.collectMatches(WidgetFinderService.java:69)
   at com.windowtester.finder.swt.SWTWidgetFinder.findAll(SWTWidgetFinder.java:70)
   at com.windowtester.runtime.WidgetLocator.findAll(WidgetLocator.java:429)
   at com.windowtester.runtime.swt.internal.UIContextSWT.findAll(UIContextSWT.java:636)
   at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:571)
   at com.windowtester.internal.runtime.selector.ClickHelper.doFind(ClickHelper.java:192)
   at com.windowtester.internal.runtime.selector.ClickHelper.click(ClickHelper.java:58)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:87)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:296)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:80)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:304)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:73)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:287)
   at com.opalrt.livelab.ui.tests.Test5.testTest5(Test5.java:41)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at junit.framework.TestCase.runTest(TestCase.java:164)
   at junit.framework.TestCase.runBare(TestCase.java:130)
   at com.windowtester.runtime.common.UITestCaseCommon.access$001(UITestCaseCommon.java:25)
   at com.windowtester.runtime.common.UITestCaseCommon$2.run(UITestCaseCommon.java:136)
   at com.windowtester.runtime.common.UITestCaseCommon$3.run(UITestCaseCommon.java:157)
   at com.windowtester.internal.runtime.junit.core.SequenceRunner$1.run(SequenceRunner.java:46)



Thanks for your help.

Vincent
hyshyshys
 
Posts: 37
Joined: Thu Jul 03, 2008 12:27 pm

Re: UnableToFindActiveShellException

Postby Phil Quitslund » Fri Mar 20, 2009 1:00 pm

Hi Vincent,

As you've gathered, that exception occurs when no SWT application window/shell has current keyboard focus. At a lower level, this happens when Display.geDefault().getActiveShell()) returns null. This commonly occurs when some other application has stolen focus (e.g., a chat or mail notification) or when the user interferes with test playback by moving the mouse or entering text (but it sounds like you've ruled this one out). Can you think of anything that might be stealing focus? Does this happen even when you are NOT running a test? Oh, and what OS are you on?

As for workarounds, in the next week we will release v3.8.0. In that release we will have a new condition handler that can force this focus. Using that API looks like this:

Code: Select all
ui.ensureThat(new WorkbenchLocator().hasFocus());\
//or using static imports
ui.ensureThat(workbench().hasFocus());


That said, we should really try to get to the bottom of what is causing focus to get lost...

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: UnableToFindActiveShellException

Postby hyshyshys » Mon Mar 23, 2009 5:47 am

Hi Phil,

Thanks for your help.

It only happens when I run tests. But all tests I made reach this exception...

I'm using :
1- Window XP Pro (Ver2002) SP3
2- Intel Core 2 CPU @ 2.4 GHz 2 GB RAM

I'm sure I don't move the mouse or click keyboard. Here are the processes that are running on my computer. I don't think any of the following processes will stole the focus.

proc.jpg
proc.jpg (85.48 KiB) Viewed 663 times


You suggest to use the new condition handler but I'm not sure it will help me, since I lost the focus. I need something to get the focus back? With this condition handler my test will freeze until I manually click on the view? What do you think?

Vincent
hyshyshys
 
Posts: 37
Joined: Thu Jul 03, 2008 12:27 pm

Re: UnableToFindActiveShellException

Postby Phil Quitslund » Mon Mar 23, 2009 12:05 pm

Hi Vincent,

The new handler should actually be able to force focus back before the test failure occurs. Please send a ticket to support (wintest-support@instantiations.com) and we will put together something to try as soon as we ship 3.8.0 and the team gets back from EclipseCon.

Thanks for following up!

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: UnableToFindActiveShellException

Postby hyshyshys » Mon Mar 23, 2009 1:24 pm

Hi Phil,

Ticket done...

Thanks
hyshyshys
 
Posts: 37
Joined: Thu Jul 03, 2008 12:27 pm

Re: UnableToFindActiveShellException

Postby 3061 » Mon Mar 30, 2009 4:35 am

I had that error lots of times.

Code: Select all
ui.wait(new ShellShowingCondition(titleTextOfWindow));

needs the exact Text String that is inside that Window. Try using the recorder and click on the title bar of that window. Sometimes, there's a space character in there ("Name "), or an unsaved project has a star in front of it ("*Name"). I recently found a typo that has been in our application for a year an no one noticed it said "open Poiect" instead of "open Project". The human mind corrects those errors without you noticing. You can even easily read text if the ltertes in the mdilde of wdors are sapwped aonrud lkie tihs. :-)
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: UnableToFindActiveShellException

Postby Phil Quitslund » Mon Mar 30, 2009 11:54 am

Good tip. Thanks!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest