これを行う直接的な方法がないためです。コンテキストメニューを開くためのショートカットがあると思います。
bot.activeShell().pressShortcut(<your shortcut>);
bot.waitUntil(new ContextMenuAppears(tree,
"New"));
tree.contextMenu("New").click();
ContextMenuAppears は、目的のコンテキスト メニューが表示されるのを待機する ICondition です。
public class ContextMenuAppears implements ICondition {
private SWTBotTree swtBotTree;
private String mMenuText;
public TekstContextMenuAppears(SWTBotTree pSwtBotTree, String menuText) {
swtBotTree = pSwtBotTree;
mMenuText = menuText;
}
@Override
public boolean test() throws Exception {
try {
return swtBotTree.contextMenu(mMenuText).isVisible();
} catch (WidgetNotFoundException e) {
return false;
}
}
@Override
public void init(SWTBot bot) {
// TODO Auto-generated method stub
}
@Override
public String getFailureMessage() {
// TODO Auto-generated method stub
return null;
}
}