WIndowTester failed to record JSpinner action

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

WIndowTester failed to record JSpinner action

Postby keico » Mon Jan 10, 2011 7:09 am

Hello,
I am trying to record an action of a JSpinner component from my swing application using the WindowTester Pro tool. The tool recorded it successfully and was able to generate a JUnit test. However, when I ran it I received a MutipleWidgetsFoundException. Below is the stack trace:

com.windowtester.runtime.MultipleWidgetsFoundException: Multiple Components found
at com.windowtester.internal.swing.UIContextSwing.find(UIContextSwing.java:196)
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 Test.test(Test.java:25)
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:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
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)

Here the test code the tool generated at line 25: ui.click(new JButtonLocator(""));

I also verified that I'd named my JSpinner (NOT JButton) component from the source code. However, I don't understand why the tool picked up a JButtonLocator here.

Does anyone have any idea how to resolve this issue?
Thanks very much for your help!
Keico
keico
 
Posts: 21
Joined: Wed Jan 05, 2011 7:37 am

Re: WIndowTester failed to record JSpinner action

Postby keertip » Tue Jan 11, 2011 12:32 pm

Attached is a sample app with a JSpinner and a working test. Take a look at it and maybe see if using the NamedWidgetLocator will help solve the problem.
Attachments
SpinnerTest.java
(751 Bytes) Downloaded 22 times
MonthSpinner.java
(1.29 KiB) Downloaded 12 times
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: WIndowTester failed to record JSpinner action

Postby keico » Wed Jan 12, 2011 6:38 am

Thanks for your response.
The tool works fine if the swing application only contain a single JSpinner component. However, it started breaking once I added another JSpinner component to the original swing app.

I attached the modified source code for the sample app and the JUnit tests that the tool generated.

Please help me investigate!
Thanks very much.
keico
Attachments
SpinnerTest5.java
This generated test file contains syntax errors.
(873 Bytes) Downloaded 8 times
SpinnerTest4.java
This generated test also contains syntax errors.
(770 Bytes) Downloaded 12 times
MonthSpinner.java
(1.53 KiB) Downloaded 12 times
keico
 
Posts: 21
Joined: Wed Jan 05, 2011 7:37 am

Re: WIndowTester failed to record JSpinner action

Postby keertip » Thu Jan 13, 2011 1:07 pm

Have made some progress on this - but not yet there. Maybe you could give it a shot. Looking at the Swing hierarchy ( do a Ctrl+shift+ F1) when the MonthSpinner application is running, saw that the arrows for the spinners were buttons of class javax.swing.plaf.basic.BasicArrowButton. So named the date spinner and the following test code worked.

Code: Select all
// next
ui.click(new SwingWidgetLocator("javax.swing.plaf.basic.BasicArrowButton",0,
            new NamedWidgetLocator("DateField")));
// previous
ui.click(new SwingWidgetLocator("javax.swing.plaf.basic.BasicArrowButton",1,
            new NamedWidgetLocator("DateField")));



For some reason the same logic did not seem to work with the NumberField spinner at first try.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: WIndowTester failed to record JSpinner action

Postby keico » Fri Jan 14, 2011 8:56 am

Thanks your posting your progress report. The logic so far only works with the FIRST JSpinner component in the swing app.
Please continue your investigation.
Thanks!
keico
keico
 
Posts: 21
Joined: Wed Jan 05, 2011 7:37 am

Re: WIndowTester failed to record JSpinner action

Postby keertip » Wed Jan 19, 2011 10:15 am

Will look into this and post an update
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Re: WIndowTester failed to record JSpinner action

Postby keico » Fri Feb 11, 2011 9:32 am

After renaming the arrows for the spinners I had this issue resolved.
Thanks for your active response!
-keico
keico
 
Posts: 21
Joined: Wed Jan 05, 2011 7:37 am

Re: WIndowTester failed to record JSpinner action

Postby keertip » Mon Feb 14, 2011 8:25 am

Great! Glad that the problem is resolved!
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