Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » SWTBot Test throws WidgetNotFoundException only when run with Maven
SWTBot Test throws WidgetNotFoundException only when run with Maven [message #1701199] Thu, 09 July 2015 19:20 Go to next message
Robert Smith is currently offline Robert SmithFriend
Messages: 1
Registered: July 2015
Junior Member
I have written a SWTBot test for an Eclipse RCP application which opens Eclipse and then opens a view. When run as an SWTBot test, it runs correctly and passes. However, when run in the project's Maven build using Tycho, it fails with the following error message:

org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: The widget was null.
	at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot.<init>(AbstractSWTBot.java:104)
	at org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl.<init>(AbstractSWTBotControl.java:47)
	at org.eclipse.swtbot.swt.finder.widgets.SWTBotShell.<init>(SWTBotShell.java:49)
	at org.eclipse.swtbot.swt.finder.widgets.SWTBotShell.<init>(SWTBotShell.java:38)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.activeShell(SWTBotFactory.java:376)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFactory.java:210)
	at org.eclipse.swtbot.swt.finder.SWTBotFactory.menu(SWTBotFactory.java:200)
	at org.eclipse.ice.viz.service.test.PlotEditorTester.checkPlotEditorFileAssociation(PlotEditorTester.java:143)


The line it fails on is:

bot.menu("Window").menu("Show View").menu("Project Explorer").click();

Specifically, it can't find the "Window" menu. It apparently isn't getting an Eclipse window. I have tried explicitly opening a workbench window like so, but it did not change the error:

		UIThreadRunnable.syncExec(new VoidResult() {
			  public void run() {
			    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
			  }
			});


The test bundle's pom.xml file includes this:

	<build>
		<plugins>
			<!-- Configure the build to handle SWTBot -->
			<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-surefire-plugin</artifactId>
				<version>${tycho-version}</version>
				<configuration>
					<useUIHarness>true</useUIHarness>
					<useUIThread>false</useUIThread>
					<product>org.eclipse.sdk.ide</product>
					<application>org.eclipse.ui.ide.workbench</application>
				</configuration>
			</plugin>
		</plugins>
	</build>


What am I doing wrong and how do I fix it?

Edit: I found the problem. I needed to add the following dependency to my pom.xml file, inside the <configuraiton> node.

					<dependencies>
						<dependency>
							<type>p2-installable-unit</type>
							<artifactId>org.eclipse.sdk.feature.group</artifactId>
						</dependency>
					</dependencies>


With that, Maven opens an Eclipse instance to run the test in, allowing it to succeed.

[Updated on: Fri, 10 July 2015 17:24]

Report message to a moderator

Re: SWTBot Test throws WidgetNotFoundException only when run with Maven [message #1701700 is a reply to message #1701199] Wed, 15 July 2015 06:43 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

is the Maven build running in a CI server, e.g., Jenkins?

In that case you must make sure a Window Manager is running (see
https://wiki.eclipse.org/SWTBot/Automate_test_execution#On_Jenkins)

hope this helps
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Previous Topic:SWTBot for Indigo
Next Topic:Still cannot get Mars working with Kali Linux
Goto Forum:
  


Current Time: Fri Apr 26 15:04:41 GMT 2024

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

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

Back to the top