← Back to team overview

sikuli-driver team mailing list archive

[Question #151842]: Sikuli cannot run in Eclipse Plug-in Projects?

 

New question #151842 on Sikuli:
https://answers.launchpad.net/sikuli/+question/151842

Hi all, I'm a tester.
Our team uses Eclipse Plug-in development (RCP) technology, and we are planning to use SWTBot to perform the GUI testing. However, SWTBot cannot handle the OS native Open File dialog. So we are trying to take these parts (all dialogs not supported by SWTBot) with Sikuli. But we didn't manage to run Sikuli successfully in an SWTBot Test Plug-in Project. The JUnit throws an NoClassDefFoundError exception every time after our testing product been run.

Please refer to the following steps we used to test the product:
1. Create an SWTBot Test Plug-in Project.
2. Add External JAR "sikuli-script.jar" to Build Path.
3. Create a test class using SWTBot to open the Open File dialog, and using Sikuli to enter the file path and click OK button.
4. Run the test class as an SWTBot Test (Changing the tab Main to run our product in Run configuration).
5. Then got the following exception in JUnit (not in the Console):

------------------------Exception Start----------------------
java.lang.NoClassDefFoundError: org/sikuli/script/FindFailed
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getConstructors(Unknown Source)
	at org.junit.runners.model.TestClass.<init>(TestClass.java:33)
	at org.junit.runners.ParentRunner.<init>(ParentRunner.java:65)
	at org.junit.runners.BlockJUnit4ClassRunner.<init>(BlockJUnit4ClassRunner.java:59)
	at org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner.<init>(SWTBotJunit4ClassRunner.java:46)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
	at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
	at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
	at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.swtbot.eclipse.core.RemotePluginTestRunner.main(RemotePluginTestRunner.java:64)
	at org.eclipse.swtbot.eclipse.core.UITestApplication.runTests(UITestApplication.java:117)
	at org.eclipse.ui.internal.testing.WorkbenchTestable$1.run(WorkbenchTestable.java:71)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.sikuli.script.FindFailed
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
	... 28 more
------------------------Exception End----------------------


And the following is the test code:
------------------------Test Code Start----------------------
package org.felix.test;

import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBotAssert;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Screen;

@RunWith(SWTBotJunit4ClassRunner.class)
public class CreateProject {

	private SWTWorkbenchBot bot;
	
	@Test
	public void openFile() throws Exception {
		bot.menu("File").menu("Open File...").click();
		Screen s = new Screen();
		try{
			s.wait("imgs/openFile-1.Dialog.png");
			s.type("imgs/openFile-2.FileName.png", "/path/to/testfile\n", 0);
		}
		catch(FindFailed e){
			e.printStackTrace();
		}
	}
	
	@Before
	public void setup() {
		bot = new SWTWorkbenchBot();
	}
}
------------------------Test Code End----------------------

The Sikuli code runs well in a normal Java Project, and the SWTBot test code runs well without Sikuli too. So the problem seems only happen in the eclipse plug-in projects. 

Any ideas? Thank you very much for any replies.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.