【发布时间】:2015-10-29 08:02:07
【问题描述】:
我正在 eclipse Juno Service Release 2 中使用 swtBot 编写自动化测试。下面是我的代码
@BeforeClass
public static void beforeClass() {
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
bot = new SWTWorkbenchBot();
try {
bot.viewByTitle("Welcome").close();
} catch (WidgetNotFoundException e) {
// ignore
}
bot.menu("Window").menu("Preferences").click();
SWTBotShell shell = bot.shell("Preferences");
shell.activate();
SWTBotView view = bot.viewByTitle("Preferences");
bot.tree().expandNode("General").select("Workspace");
SWTBotCheckBox buildAuto = bot.checkBox("Build automatically");
if (buildAuto != null && buildAuto.isChecked())
buildAuto.click();
bot.button("Apply").click();
bot.tree().expandNode("General").select("Perspectives");
SWTBotRadio radio = bot.radio("Always open");
if (radio != null && !radio.isSelected())
radio.click();
bot.button("OK").click();
}
我收到以下异常:
org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException: 找不到外壳匹配:带有文本“首选项”在 org.eclipse.swtbot.swt.finder.SWTBotFactory.waitUntilWidgetAppears(SWTBotFactory.java:387) 在 org.eclipse.swtbot.swt.finder.SWTBotFactory.shells(SWTBotFactory.java:114) 在 org.eclipse.swtbot.swt.finder.SWTBotFactory.shell(SWTBotFactory.java:104) 在 org.eclipse.swtbot.swt.finder.SWTBotFactory.shell(SWTBotFactory.java:95) 在 com.packtpub.e4.junit.plugin.UITest.beforeClass(UITest.java:49) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)在 java.lang.reflect.Method.invoke(未知来源)
【问题讨论】: