NullPointerException in deep parts of Window Tester

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

NullPointerException in deep parts of Window Tester

Postby sazaju » Mon Apr 18, 2011 7:53 am

Hi,

I have followed the steps of the official SWT example (here) and have had some classes not found (more than the quoted ones at the end of the example). I have looked for the corresponding JARs over the Web and it have progressed... until I reach this error :

Code: Select all
com.windowtester.runtime.swt.internal.widgets.SWTUIException: Exception occurred on the SWT UI Thread
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.run(SWTUIExecutor.java:101)
   at com.windowtester.runtime.swt.internal.widgets.DisplayReference.execute(DisplayReference.java:121)
   at com.windowtester.runtime.swt.internal.widgets.DisplayReference.execute(DisplayReference.java:100)
   at com.windowtester.runtime.swt.internal.widgets.finder.SWTWidgetFinder.doFindAll(SWTWidgetFinder.java:106)
   at com.windowtester.runtime.swt.internal.widgets.finder.SWTWidgetFinder.findAll(SWTWidgetFinder.java:100)
   at com.windowtester.runtime.swt.locator.SWTWidgetLocator.findAll(SWTWidgetLocator.java:302)
   at com.windowtester.runtime.swt.internal.UIContextSWT.findAll(UIContextSWT.java:631)
   at com.windowtester.runtime.swt.internal.UIContextSWT.find(UIContextSWT.java:546)
   at com.windowtester.internal.runtime.selector.ClickHelper.doFind(ClickHelper.java:187)
   at com.windowtester.internal.runtime.selector.ClickHelper.click(ClickHelper.java:52)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:140)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:325)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:133)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:333)
   at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:126)
   at com.windowtester.runtime.swt.internal.UIContextSWT.click(UIContextSWT.java:295)
   at com.demo.SampleTest.testTest1(SampleTest.java:23)
   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$0(UITestCaseCommon.java:1)
   at com.windowtester.runtime.common.UITestCaseCommon$2.run(UITestCaseCommon.java:130)
   at com.windowtester.runtime.common.UITestCaseCommon$3.run(UITestCaseCommon.java:151)
   at com.windowtester.internal.runtime.junit.core.SequenceRunner$1.run(SequenceRunner.java:40)
Caused by: com.windowtester.runtime.swt.internal.widgets.SWTUIException: Exception occurred on the SWT UI Thread
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.run(SWTUIExecutor.java:101)
   at com.windowtester.runtime.swt.internal.widgets.DisplayReference.execute(DisplayReference.java:121)
   at com.windowtester.runtime.swt.internal.widgets.DisplayReference.execute(DisplayReference.java:100)
   at com.windowtester.runtime.swt.internal.widgets.CompositeReference.getChildControls(CompositeReference.java:22)
   at com.windowtester.runtime.swt.internal.widgets.CompositeReference.setChildren(CompositeReference.java:31)
   at com.windowtester.runtime.swt.internal.widgets.DecorationsReference.setChildren(DecorationsReference.java:64)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference$1.call(SWTWidgetReference.java:111)
   at com.windowtester.runtime.swt.internal.SWTUtils.safeExec(SWTUtils.java:58)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.getChildren(SWTWidgetReference.java:108)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.accept(SWTWidgetReference.java:296)
   at com.windowtester.runtime.swt.internal.widgets.finder.MatchCollector.findMatchesIn(MatchCollector.java:55)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.findWidgets(SWTWidgetReference.java:285)
   at com.windowtester.runtime.swt.internal.widgets.finder.SWTWidgetFinder$1.call(SWTWidgetFinder.java:112)
   at com.windowtester.runtime.swt.internal.widgets.finder.SWTWidgetFinder$1.call(SWTWidgetFinder.java:1)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.execute(SWTUIExecutor.java:132)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.access$0(SWTUIExecutor.java:130)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor$1.run(SWTUIExecutor.java:91)
   at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
   at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
   at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
   at com.demo.AddressBookUI.main(AddressBookUI.java:135)
   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 com.windowtester.internal.runtime.junit.core.launcher.LauncherFactory$MainRunner$1.run(LauncherFactory.java:121)
   at com.windowtester.internal.runtime.junit.core.launcher.LauncherFactory$SeparateThreadLauncher$1.run(LauncherFactory.java:90)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Failed to create widget reference for instance of org.eclipse.swt.widgets.Button
   WindowTester: 201009131510 - win32,win32,x86
   factory: com.windowtester.runtime.internal.factory.WTRuntimeFactoryReference$1@1b60280
   at com.windowtester.runtime.internal.factory.WTRuntimeManager.createReference(WTRuntimeManager.java:95)
   at com.windowtester.runtime.internal.factory.WTRuntimeManager.asReference(WTRuntimeManager.java:36)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.forWidget(SWTWidgetReference.java:315)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.asControlReferences(SWTWidgetReference.java:234)
   at com.windowtester.runtime.swt.internal.widgets.CompositeReference$1.call(CompositeReference.java:24)
   at com.windowtester.runtime.swt.internal.widgets.CompositeReference$1.call(CompositeReference.java:1)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.execute(SWTUIExecutor.java:132)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.run(SWTUIExecutor.java:87)
   ... 28 more


This is the trace of the JUnit execution, and on the console I get this one :

Code: Select all
java.lang.NullPointerException
   at com.windowtester.runtime.internal.factory.WTRuntimeFactoryReferenceJava.createFactory(WTRuntimeFactoryReferenceJava.java:185)
   at com.windowtester.runtime.internal.factory.WTRuntimeFactoryReference.getFactory(WTRuntimeFactoryReference.java:70)
   at com.windowtester.runtime.internal.factory.WTRuntimeFactoryReference.createReference(WTRuntimeFactoryReference.java:57)
   at com.windowtester.runtime.internal.factory.WTRuntimeManager.createReference(WTRuntimeManager.java:87)
   at com.windowtester.runtime.internal.factory.WTRuntimeManager.asReference(WTRuntimeManager.java:36)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.forWidget(SWTWidgetReference.java:315)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.asControlReferences(SWTWidgetReference.java:234)
   at com.windowtester.runtime.swt.internal.widgets.CompositeReference$1.call(CompositeReference.java:24)
   at com.windowtester.runtime.swt.internal.widgets.CompositeReference$1.call(CompositeReference.java:1)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.execute(SWTUIExecutor.java:132)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.run(SWTUIExecutor.java:87)
   at com.windowtester.runtime.swt.internal.widgets.DisplayReference.execute(DisplayReference.java:121)
   at com.windowtester.runtime.swt.internal.widgets.DisplayReference.execute(DisplayReference.java:100)
   at com.windowtester.runtime.swt.internal.widgets.CompositeReference.getChildControls(CompositeReference.java:22)
   at com.windowtester.runtime.swt.internal.widgets.CompositeReference.setChildren(CompositeReference.java:31)
   at com.windowtester.runtime.swt.internal.widgets.DecorationsReference.setChildren(DecorationsReference.java:64)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference$1.call(SWTWidgetReference.java:111)
   at com.windowtester.runtime.swt.internal.SWTUtils.safeExec(SWTUtils.java:58)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.getChildren(SWTWidgetReference.java:108)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.accept(SWTWidgetReference.java:296)
   at com.windowtester.runtime.swt.internal.widgets.finder.MatchCollector.findMatchesIn(MatchCollector.java:55)
   at com.windowtester.runtime.swt.internal.widgets.SWTWidgetReference.findWidgets(SWTWidgetReference.java:285)
   at com.windowtester.runtime.swt.internal.widgets.finder.SWTWidgetFinder$1.call(SWTWidgetFinder.java:112)
   at com.windowtester.runtime.swt.internal.widgets.finder.SWTWidgetFinder$1.call(SWTWidgetFinder.java:1)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.execute(SWTUIExecutor.java:132)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor.access$0(SWTUIExecutor.java:130)
   at com.windowtester.runtime.swt.internal.widgets.SWTUIExecutor$1.run(SWTUIExecutor.java:91)
   at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
   at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
   at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
   at com.demo.AddressBookUI.main(AddressBookUI.java:135)
   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 com.windowtester.internal.runtime.junit.core.launcher.LauncherFactory$MainRunner$1.run(LauncherFactory.java:121)
   at com.windowtester.internal.runtime.junit.core.launcher.LauncherFactory$SeparateThreadLauncher$1.run(LauncherFactory.java:90)
   at java.lang.Thread.run(Unknown Source)


What do you think about it ?

If it can help, I have tried the Swing sample and it was impossible to generate any test, as the application stops immediately after the launch of the recording (stopping the recording itself). This problem is only in recording mode, The application run well alone (I have tried with another Swing app and it is the same). I have tried it on 2 different computers (Windows 7 64bits + Windows XP 32bits), with Eclipse 3.6 & JDK 1.6.
sazaju
 
Posts: 7
Joined: Thu Apr 14, 2011 4:17 am

Re: NullPointerException in deep parts of Window Tester

Postby gnebling » Mon Apr 18, 2011 1:43 pm

Sounds like an installation/configuration issue. Please note that WindowTester does not support 64bits.
Do you get the SWT error when recording or during playback?

Try to add the following jar files to your Test project's classpath:
wt-win32-win32-x86.jar under com.windowtester.swt.runtime.win32.win32.x86
org.eclipse.swt.win32.win32.x86
org.eclipse.ui.workbench

If that doesn't help and if you haven't tried already, please try with a fresh install of Eclipse.
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Re: NullPointerException in deep parts of Window Tester

Postby sazaju » Tue Apr 19, 2011 11:36 pm

Sorry for the late, some network access problems {'^_^}.

I have already added these JARs (because of this problem). Moreother, as detailed above, this problem concerns also 32 bits architecture. On both machines it was done on a fresh Eclipse installation (the Java EE version downloaded here).

The SWT error occurs on the playback, recording just work well, here is the test generated :
Code: Select all
package com.demo;

import com.windowtester.runtime.swt.UITestCaseSWT;
import com.windowtester.runtime.swt.locator.LabeledTextLocator;
import com.windowtester.runtime.IUIContext;
import com.windowtester.runtime.WT;
import com.windowtester.runtime.swt.locator.ShellLocator;

public class SampleTest extends UITestCaseSWT {

   /**
    * Create an Instance
    */
   public SampleTest() {
      super(com.demo.AddressBookUI.class);
   }

   /**
    * Main test method.
    */
   public void testSampleTest() throws Exception {
      IUIContext ui = getUI();
      ui.click(new LabeledTextLocator("First Name:"));
      ui.enterText("aze");
      ui.keyClick(WT.TAB);
      ui.enterText("sdf");
      ui.ensureThat(new ShellLocator("Address Book").isClosed());
   }
}
sazaju
 
Posts: 7
Joined: Thu Apr 14, 2011 4:17 am

Re: NullPointerException in deep parts of Window Tester

Postby sazaju » Wed Apr 20, 2011 5:26 am

Is the source code of WindowTester available ? So I can see exactly what is the error.
sazaju
 
Posts: 7
Joined: Thu Apr 14, 2011 4:17 am

Re: NullPointerException in deep parts of Window Tester

Postby gnebling » Wed Apr 20, 2011 12:04 pm

I tried the exact same thing using Eclipse for Java EE SR2 on WinXP machine and after adding the missing jars, the playback worked. Here is a screenshot of the jars I added. In addition to the files mentioned in the previous posting, I also added the org.eclipse.ui.forms jar. See if we have the exact same files.
Attachments
externaljars.jpg
externaljars.jpg (110.02 KiB) Viewed 97 times
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Re: NullPointerException in deep parts of Window Tester

Postby gnebling » Wed Apr 20, 2011 12:07 pm

sazaju wrote:Is the source code of WindowTester available ?

No
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am

Re: NullPointerException in deep parts of Window Tester

Postby sazaju » Wed Apr 20, 2011 10:29 pm

Yes it works ! {^_^}b

My error was to put the JARs in the classpath of the running configuration instead of the project, more exactly in the Bootstrap entries.
Image

Thank you very much {^_^}.
sazaju
 
Posts: 7
Joined: Thu Apr 14, 2011 4:17 am

Re: NullPointerException in deep parts of Window Tester

Postby gnebling » Thu Apr 21, 2011 7:14 am

You're welcome. Glad that works.
gnebling
Moderator
 
Posts: 243
Joined: Tue Aug 22, 2006 7:49 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest

cron