Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » SWTBot can't find the "File" menu
SWTBot can't find the "File" menu [message #479947] Thu, 13 August 2009 08:11 Go to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 146
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030206060208010501050908
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I've got a very strange issue and I don't know where to look for to fix
it. In some Eclipse configuration I use, SWTBot does not work at all: it
fails the very first method with a WidgetNotFoundException.

The test is org.eclipse.gef.example.logic.test.OpenGefEditor, from [1]
but it doesn't seem to be doing anything special.

Using one Eclipse installation it works perfectly. Using another, it
fails at the first SWTBot method. In both cases, this is under Windows
XP SP2, Java 1.6, but it looks like the behavior is the same under Linux.

- First configuration (where it works):
- Eclipse 3.5 Modeling Package
- SWTBot for SWT Testing 2.0.0.371-dev-e35
- SWTBot for Eclipse Testing 2.0.0.371-dev-e35
- SWTBot4Gef Feature 0.1.0.200907301531

In this configuration, the test works. I get a warning from log4j
because "No appenders could be found", but the test itself passes.

- Second configuration (where it fails)
- Topcased RCP 3.0.1 from [2]
- Same versions of SWTBot and SWTBot4Gef

In this configuration, the runtime Eclipse launches, I see the
welcome page, and then:
- when the code tries to access the Welcome view to close it =>
WidgetNotFoundException. It is normally ignored, but I've added a
printStackTrace() to confirm it is thrown.
- the test continues and tries a bot.menu("File"), which fails with a
timeout. The file menu is present in the Eclipse under test, which
itself is in focus.

What is even stranger is that in the second configuration, Log4J is
enabled and tells me repeatedly that it "matched MenuItem with text
"&File", using matcher: with mnemonic 'File" until the caller timeouts.

Apart for some preinstalled features and branding, Topcased RCP looks
very much like a standard Eclipse. It launches on a normal workbench,
with a Welcome page, and standard menus (include "File"). I attach the
logs I get while running the failing test and the final stack trace from
JUnit.

I have no idea about what difference in both configurations can cause
the problem. Any hint about where to look for?

Thanks.

[1]
http://code.google.com/p/swtbot4gef/source/browse/#svn/trunk /org.eclipse.swtbot4gef/examples

[2] http://www.topcased.org/index.php?idd_projet_pere=52&Ite mid=60

--------------030206060208010501050908
Content-Type: text/plain;
name="logs.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="logs.txt"

org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion: Could not find widget.
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetA ppears(SWTBotFactory.java:346)
at org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot.view(SWTWo rkbenchBot.java:122)
at org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot.viewByTitl e(SWTWorkbenchBot.java:135)
at org.eclipse.gef.examples.logic.test.OpenGefEditorTest.closeW elcomePage(OpenGefEditorTest.java:35)
at org.eclipse.gef.examples.logic.test.OpenGefEditorTest.setUp( OpenGefEditorTest.java:29)
at junit.framework.TestCase.runBare(TestCase.java:132)
at org.eclipse.swtbot.swt.finder.SWTBotTestCase.runBare(SWTBotT estCase.java:228)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38Cla ssRunner.java:79)
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(Unknown Source)
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find view matching: with name '"Welcome"'
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:396)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:370)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:358)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetA ppears(SWTBotFactory.java:344)
... 22 more
0 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
540 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
1041 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
1542 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
2043 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
2543 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
3054 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
3575 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
4076 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
4606 [main] DEBUG org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher - matched MenuItem with text "&File", using matcher: with mnemonic 'File'
5107 [main] DEBUG org.eclipse.swtbot.swt.finder.utils.SWTUtils - Capturing screenshot 'screenshots/screenshot-OpenGefEditorTest.testCreateFile.jpe g'

--------------030206060208010501050908
Content-Type: text/plain;
name="stacktrace.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="stacktrace.txt"

org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundExcep tion: Could not find widget.
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetA ppears(SWTBotFactory.java:346)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFacto ry.java:255)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFacto ry.java:206)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFacto ry.java:196)
at org.eclipse.gef.examples.logic.test.NewEmptyEmfProject.creat eProject(NewEmptyEmfProject.java:26)
at org.eclipse.gef.examples.logic.test.OpenGefEditorTest.testCr eateFile(OpenGefEditorTest.java:48)
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 org.eclipse.swtbot.swt.finder.SWTBotTestCase.runBare(SWTBotT estCase.java:228)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38Cla ssRunner.java:79)
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(Unknown Source)
Caused by: org.eclipse.swtbot.swt.finder.widgets.TimeoutException: Timeout after: 5000 ms.: Could not find a menu within the shell 'Shell with text {Shell {Resource - Eclipse P...}}' matching 'with mnemonic 'File''
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:396)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:370)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntil(SWTBot Factory.java:358)
at org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetA ppears(SWTBotFactory.java:344)
... 28 more


--------------030206060208010501050908--
Re: SWTBot can't find the "File" menu [message #480051 is a reply to message #479947] Thu, 13 August 2009 15:00 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 146
Registered: July 2009
Senior Member
Pierre-Charles David a écrit :
> Hi,
>
> I've got a very strange issue and I don't know where to look for to fix
> it. In some Eclipse configuration I use, SWTBot does not work at all: it
> fails the very first method with a WidgetNotFoundException.
[snip]

Well, I found the issue:

SWTBot declares a dependency to org.apache.log4j but does not indicate
any specific version. However, it uses APIs which only appeared in log4j
1.2.12 (at least Logger.trace(), maybe others).

In the Eclipse installation I have which did not work ("Topcased RCP"),
there was a bundle which provided the org.apache.log4j package, but
using log4j version 1.2.8. As it happens, Eclipse decided to provide
this one to SWTBot instead of other versions available from different
bundles (1.2.12 and 1.2.15). The test failed with an internal
NoSuchMethodError, which must have been caught by some code and wrapped
as the WidgetNotFoundException I saw.

Removing the plugin with log4j 1.2.8 from the test's run configuration
solves the issue.

I have opened bug #286527 about this.
Previous Topic:[swtbot4gef] Why is the constructor of SWTBotEditPart and SwtBotConnectionEditPart package-private?
Next Topic:autocomplete?
Goto Forum:
  


Current Time: Mon Dec 22 06:28:51 GMT 2014

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

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