我们在构建服务器上得到一个AssertionFailedException,但测试在集成开发环境中启动时运行良好。
Build-Job在Windows上运行,而不是作为服务运行,因此这应该不是问题。
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:41)
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)发布于 2014-07-25 20:41:58
我们尝试发送CR-key,并找到了以下解决方法。我们没有向操作系统发送事件并等待操作系统回复defaultSelection事件,而是自己发送了defaultSelection事件。我们的原始代码如下所示:
KeyboardFactory.getSWTKeyboard().pressShortcut(Keystrokes.CR);然后我们将其替换为:
final Event event = new Event();
SWTBot bot = new SWTBot();
SWTBotList variableList = bot.listWithId(DIALOG_LIST);
event.type = SWT.DefaultSelection;
event.display = bot.getDisplay();
event.widget = variableList.widget;
event.time = (int) System.currentTimeMillis();
bot.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
variableList.widget.notifyListeners(SWT.DefaultSelection, event);
}
});这解决了我们的问题。
https://stackoverflow.com/questions/24928154
复制相似问题