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 Go to next message
Michal Masarik is currently offline Michal MasarikFriend
Messages: 1
Registered: June 2015
Junior Member

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.
public void testOpeningFileViewerByEnterButton() {
   	        explorerNavigator.expandPath("swtbot [2]/příliš žluťoučký kůň.txt");
		Keyboard key = KeyboardFactory.getSWTKeyboard();

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

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

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

first variant of test fail with this stacktrace
Error Message
assertion failed: Could not post keyevent.
org.eclipse.swtbot.swt.finder.exceptions.AssertionFailedException: assertion failed: Could not post keyevent.
	at org.eclipse.swtbot.swt.finder.utils.internal.Assert.isTrue(
	at org.eclipse.swtbot.swt.finder.keyboard.SWTKeyboardStrategy.pressKey(
	at org.eclipse.swtbot.swt.finder.keyboard.AbstractKeyboardStrategy.pressKeys(
	at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressKeys(
	at org.eclipse.swtbot.swt.finder.keyboard.Keyboard.pressShortcut(

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


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
	public static void setUpBeforeClass() throws Exception {
		bot = new SWTWorkbenchBot();
		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
					<!-- <appArgLine>-data @noDefault</appArgLine> -->
						<!---XX:MaxPermSize=400m -->
						<!---Doracle.jdbc.timezoneAsRegion=false -->

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
Re: Problems with Keyboard when tests running headless [message #1831750 is a reply to message #1698211] Fri, 28 August 2020 06:05 Go to previous message
Felix Bruckner is currently offline Felix BrucknerFriend
Messages: 3
Registered: December 2019
Junior Member
Hi @Michael,
could you solve the problem? I'm running into a wall in my project regarding the same/a similar problem...
Best Regards
Previous Topic:SWTBot on Jenkins Bitvise SSH-Server
Next Topic:SWTBot _Tycho
Goto Forum:

Current Time: Thu Jul 18 03:26:50 GMT 2024

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

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

Back to the top