简体   繁体   中英

SWTBot eclipse - How to terminate (stop project) a running project

I'm trying to stop a running project using SWTBot plug-in (for Automation testing). I've tried to terminate the project with the following command:

bot.toolbarButtonWithTooltip("Terminate").click();

but it doesn't work! also, I thought the problem is with element Focus issue, I fixed that with:

// Go to Console window (focus)
KeyboardFactory.getAWTKeyboard().pressShortcut(Keystrokes.ALT,Keystrokes.SHIFT,KeyStroke.getInstance(0, 'Q'));
bot.sleep(100);
KeyboardFactory.getAWTKeyboard().pressShortcut(KeyStroke.getInstance(0, 'C'));
bot.sleep(3000);
// TODO: try to terminate project
bot.toolbarButtonWithTooltip("Terminate").click();

but still it doesn't work!!

I also tried to use bot.Button() instead of toolbarButtonWithTooltip(), and also it doesn't work...

Thanks

尝试传递索引而不是字符串来访问工具栏按钮,或者可以从“运行”菜单终止:

bot.menu("Run").menu("Terminate").click();

Try to add '&' at the beginning of your toolbar button string. Works for me.

bot.toolbarButtonWithTooltip("&Terminate").click();

I used this solution and it's working, I changed the Run to Debug Perspective, and after that selected the project form the tree and clicked Terminate...

AllTestSuite.bot.menu("Window").menu("Open Perspective").menu("Other...").click();
SWTBotShell openPerspectiveShell = AllTestSuite.bot.shell("Open Perspective");
openPerspectiveShell.activate();
AllTestSuite.bot.sleep(1000);
AllTestSuite.bot.table().select("Debug");
AllTestSuite.bot.button("OK").click();

System.err.println("after debug window");
AllTestSuite.bot.sleep(1000);

AllTestSuite.bot.tree().setFocus();
AllTestSuite.bot.tree().getTreeItem("Analog_input [C/C++ Remote Application]").select();
AllTestSuite.bot.sleep(1000);
AllTestSuite.bot.menu("Terminate").click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM