Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Problems with Keyboard when tests running headless
Problems with Keyboard when tests running headless [message #1698211] Fri, 12 June 2015 08:06
Michal Masarik is currently offline Michal MasarikFriend
Messages: 1
Registered: June 2015
Junior Member
Hello,

I have problem to pass some of my tests in case swtbot runs headlessly. I 'm testing RCP application written in E4. I'm using Jenkins for building tests (not installed as service) I'm also using Tycho and Maven. Tests are running on Windows 7 platform which is running virtually in VMWare. In case I trying to run tests in Eclipse IDE, tests passed OK. Even if I remotely watch desktop of running test in virtual Windows, I can see how swtbot works and tests passed OK. Problem occurs, If I close remote desktop connection. In this case all tests, which are probably using Keybord class fails.

I e.g. tried following variants of pressing shortcuts.
@Test
public void testOpeningFileViewerByEnterButton() {
   	        explorerNavigator.expandPath("swtbot [2]/příliš žluťoučký kůň.txt");
		Keyboard key = KeyboardFactory.getSWTKeyboard();
		key.pressShortcut(Keystrokes.CR);
		checkFileViewerIsOpened();
	}

@Test
public void testOpeningFileViewerByEnterButton2() {
		explorerNavigator.expandPath("swtbot [2]/příliš žluťoučký kůň.txt");
		bot.tree().pressShortcut(SWT.NONE, '\n');
		checkFileViewerIsOpened();
	}

@Test
public void testOpeningFileViewerByEnterButton3() {
		final SWTBotTreeItem item = explorerNavigator
				.expandPath("swtbot [2]/příliš žluťoučký kůň.txt");
		item.select();
		item.pressShortcut(SWT.NONE, '\n');
		checkFileViewerIsOpened();
	}

@Test
public void testOpeningFileViewerByEnterButton4() {
		final SWTBotTreeItem item = explorerNavigator
				.expandPath("swtbot [2]/příliš žluťoučký kůň.txt");
		item.select();
		item.pressShortcut(SWT.CR, SWT.LF);
		checkFileViewerIsOpened();
	}


first variant of test fail with this stacktrace
Error Message
assertion failed: Could not post keyevent.
Stacktrace
org.eclipse.swtbot.swt.finder.exceptions.AssertionFailedException: assertion failed: Could not post keyevent.
	at org.eclipse.swtbot.swt.finder.utils.internal.Assert.isTrue(Assert.java:95)
	at org.eclipse.swtbot.swt.finder.keyboard.SWTKeyboardStrategy.pressKey(SWTKeyboardStrategy.java:50)
	at org.eclipse.swtbot.swt.finder.keyboard.AbstractKeyboardStrategy.pressKeys(AbstractKeyboardStrategy.java:56)
	at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressKeys(Keyboard.java:157)
	at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressShortcut(Keyboard.java:123)
	at com.dell.tfh.test.hdfs.explorer.OpenFileViewerTest.testOpeningFileViewerByEnterButton(OpenFileViewerTest.java:127)


other three variants tests just do not press shortcut and fails inside my check method checkFileViewerIsOpened();

Also
bot.text("foo").typeText("text");

doesn't work similary for me. If I can watch remotely desktop, it works. If I close remote connection, tests going to fail, because it just doesn't insert text into field at all. I think It could has relationship with above problems, because it internally works with Keyboard class.

I'm setting keyboard layout in before class
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		bot = new SWTWorkbenchBot();
		perspectiveToolbarNavigator.switchHDFSPerspective();
		explorerNavigator = new ExplorerNavigator(bot.tree());
		
		SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
         }


This is part of my pom.xml. I'm setting useUIHarness=true (otherwise it doesn't work at all) and useUIThread=false
	<plugin>
				<groupId>org.eclipse.tycho</groupId>
				<artifactId>tycho-surefire-plugin</artifactId>
				<version>${tycho-version}</version>
				<configuration>
					<forkedProcessTimeoutInSeconds>72000</forkedProcessTimeoutInSeconds>
					<testRuntime>p2Installed</testRuntime>
					<profileName>DefaultProfile</profileName>
					<work>${project.build.directory}/work/tfh</work>
					<testSuite>com.dell.tfh.test</testSuite>
					<testClass>com.dell.tfh.test.suite.TestSuite</testClass>
					<useUIHarness>true</useUIHarness>
					<useUIThread>false</useUIThread>
					<application>org.eclipse.e4.ui.workbench.swt.E4Application</application>
					<product>com.dell.tfh.gui.product</product>
					<!-- <appArgLine>-data @noDefault</appArgLine> -->
					<appArgLine>
						-Dfile.encoding=UTF-8
						-Djava.security.krb5.realm=""
					</appArgLine>
					<argLine>
						<!---XX:MaxPermSize=400m -->
						<!---Doracle.jdbc.timezoneAsRegion=false -->
						-Dorg.eclipse.swtbot.keyboard.layout=EN_US
						-Duser.language=en
						-Duser.region=US
						-Dequinox.ds.print=true
						-Dequinox.ds.debug=false
						-Dequinox.scr.waitTimeOnBlock=10000
						-Dequinox.ds.block_timeout=15000
					</argLine>
					<includes>
						<include>**/TestSuite.java</include>
					</includes>
					<systemProperties>
						<log4j.test.configuration>${project.build.outputDirectory}/log4j.properties</log4j.test.configuration>
					</systemProperties>
				</configuration>
			</plugin>


I read lot of manuals, forums, googled for solving problem. I spent really lot of time to solve this, but I was unable to fix this problem so far. Could anyone please help me. I would really be happy if I could test shortcuts in my night test builds without remote desktop connection. I can provide more information if you ask, but now I don't know what exactly could help. I think it could be more configuration problem than anything else.

Thanks for any advice
Previous Topic:swtbot-how to change the facet version in Project Facets wizard
Next Topic:Selecting a Part from a Part Stack
Goto Forum:
  


Current Time: Thu Nov 15 16:41:13 GMT 2018

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

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

Back to the top