Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » WidgetNotFound when looking for menu item?
WidgetNotFound when looking for menu item? [message #507870] Thu, 14 January 2010 22:48 Go to next message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
I'm testing the JDT as an exercise, in preparation for testing our own
IDEs (we've got a few in IMP).

The following attempt to resolve "Run" -> "Run As" -> "Java Application"
consistently fails:

SWTBotMenu runMenu= bot.menu("Run");
SWTBotMenu runAsMenu= runMenu.menu("Run As");

srcEditor.setFocus(); // necessary?

SWTBotMenu runJavaAppItem= runAsMenu.menu("Java Application");
runJavaAppItem.click();

When this code begins to run, the variable 'srcEditor' refers to a Java
editor containing a class with an appropriate main(String[]) method (a
subsequent part of the test successfully executes this main() method).
Moreover, this editor has focus, so I think the call to setFocus() is
unnecessary.

Any clues as to why this fails?

--
Cheers,
-- Bob

--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
Re: WidgetNotFound when looking for menu item? [message #508028 is a reply to message #507870] Fri, 15 January 2010 15:16 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Robert M. Fuhrer wrote:

> srcEditor.setFocus(); // necessary?

No, since the setFocus() doesn't do anything right now...

> When this code begins to run, the variable 'srcEditor' refers to a Java
> editor containing a class with an appropriate main(String[]) method (a
> subsequent part of the test successfully executes this main() method).
> Moreover, this editor has focus, so I think the call to setFocus() is
> unnecessary.
>
> Any clues as to why this fails?
>

I'd like to know more about your failure. Is it an assert that fails or
an exception? What's the error message? At which line does it fail?

Also, I haven't tested much the menus with SWTBot, only thing I can say
is that sometime some of my tests fail because they can't find the File
menu... however, I haven't tried to consistently reproduce this
behavior, so it doesn't really classify as a bug, yet.

--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: WidgetNotFound when looking for menu item? [message #508098 is a reply to message #508028] Fri, 15 January 2010 21:42 Go to previous messageGo to next message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
It fails with a WidgetNotFoundException at the line that reads

SWTBotMenu runJavaAppItem = runAsMenu.menu("Java Application");

Here's the backtrace:

org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion: The widget was null.
at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot.<init>(AbstractSWTBot.java:97)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu.<init>(SWTBotMenu.java:42)
at org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu.menu(SWTBot Menu.java:96)
at swtbot.example.SWTTest1.jdtSmokeTest(SWTTest1.java:227)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall( FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(Refl ectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(Fr ameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate( InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(Ru nBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(Run Afters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit 4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit 4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java :180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java: 41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java: 173)
at org.junit.internal.runners.statements.RunBefores.evaluate(Ru nBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(Run Afters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner. run(SWTBotJunit4ClassRunner.java:54)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:390)
at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main( RemotePluginTestRunner.java:64)
at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(U ITestApplication.java:117)
at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(Work benchTestable.java:71)
at java.lang.Thread.run(Thread.java:637)


On 1/15/10 10:16 AM, Pascal Gelinas wrote:
> Robert M. Fuhrer wrote:
>
>> srcEditor.setFocus(); // necessary?
>
> No, since the setFocus() doesn't do anything right now...
>
>> When this code begins to run, the variable 'srcEditor' refers to a Java
>> editor containing a class with an appropriate main(String[]) method (a
>> subsequent part of the test successfully executes this main() method).
>> Moreover, this editor has focus, so I think the call to setFocus() is
>> unnecessary.
>>
>> Any clues as to why this fails?
>>
>
> I'd like to know more about your failure. Is it an assert that fails or
> an exception? What's the error message? At which line does it fail?
>
> Also, I haven't tested much the menus with SWTBot, only thing I can say
> is that sometime some of my tests fail because they can't find the File
> menu... however, I haven't tried to consistently reproduce this
> behavior, so it doesn't really classify as a bug, yet.


--
Cheers,
-- Bob

--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
Re: WidgetNotFound when looking for menu item? [message #508103 is a reply to message #508098] Fri, 15 January 2010 17:22 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Robert M. Fuhrer wrote:
> It fails with a WidgetNotFoundException at the line that reads
>
> SWTBotMenu runJavaAppItem = runAsMenu.menu("Java Application");
>

Hmmmm, on my Run > Run As menu, it's "1 Java Application" the label when
I have an editor with a main method. Might be your problem.

--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: WidgetNotFound when looking for menu item? [message #508105 is a reply to message #508103] Fri, 15 January 2010 22:29 Go to previous message
Robert M. Fuhrer is currently offline Robert M. FuhrerFriend
Messages: 294
Registered: July 2009
Senior Member
On 1/15/10 5:20 PM, Pascal Gelinas wrote:
> Robert M. Fuhrer wrote:
>> It fails with a WidgetNotFoundException at the line that reads
>>
>> SWTBotMenu runJavaAppItem = runAsMenu.menu("Java Application");
>>
>
> Hmmmm, on my Run > Run As menu, it's "1 Java Application" the label when
> I have an editor with a main method. Might be your problem.

That was it! I didn't realize the "1 " prefix was part of the menu label;
I thought it was some sort of decorator.

Thanks!!!

--
Cheers,
-- Bob

--------------------------------
Robert M. Fuhrer
Research Staff Member
Programming Technologies Dept.
IBM T.J. Watson Research Center

IDE Meta-tooling Platform Project Lead (http://www.eclipse.org/imp)
X10: Productive High-Performance Parallel Programming (http://x10.sf.net)
Previous Topic:Can't access Console view?
Next Topic:How to access the JDT "quick outline" pop-up?
Goto Forum:
  


Current Time: Tue Apr 16 13:24:26 GMT 2024

Powered by FUDForum. Page generated in 3.93122 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top