Test code throws WidgetNotFoundException

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

Test code throws WidgetNotFoundException

Postby keico » Thu Mar 03, 2011 3:07 pm

Hello,

My test code throws a WidgetNotFoundException at runtime. Below is the stack trace I received:

com.windowtester.runtime.WidgetNotFoundException: Component not found WidgetLocator(javax.swing.JTable):
class=class javax.swing.JFrame
name=frame0
title=SimpleTableDemo
at com.windowtester.internal.swing.UIContextSwing.find(UIContextSwing.java:200)
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.internal.swing.UIContextSwing.click(UIContextSwing.java:57)
at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:133)
at com.windowtester.internal.runtime.UIContextCommon.click(UIContextCommon.java:126)
at ClickRow.testClickRow(ClickRow.java:20)
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)

I believe the cause of the exception is because the JTable variable in the main class was instantiated to an object with type of anonymous and subclass of the javax.swing.JTable class. Please refer to the modified SimpleTableDemo.java line 77 for details.

Does anyone know the fix for this issue? Your help is greatly appreciated!

Thank you.
-keico
Attachments
ClickFirstRow.java
Java test code generated by WindowTester Pro tool
(672 Bytes) Downloaded 11 times
SimpleTableDemo.java
Modified source code
(5.45 KiB) Downloaded 9 times
SimpleTableDemo.java
Original Source Code
(4.78 KiB) Downloaded 5 times
keico
 
Posts: 21
Joined: Wed Jan 05, 2011 7:37 am

Re: Test code throws WidgetNotFoundException

Postby keertip » Fri Apr 01, 2011 8:29 am

Hmm.. this is indeed as you said. The JTable is being created as an anonymous class, which is why WT is unable to find it. Unfortunately I don't know how we would overcome this, since in order to find a table, WT does look for the JTable or children of its class. If you do a CTRL+SHFT+F1 when the Swing application has focus, you will see a print of the hierarchy tree in the console for verification.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest

cron