简体   繁体   中英

SWTBot in eclipse- How to find a project's popup menu (right click menu)

In my SWTBot test, I'm trying to open (and click) the menu that appears when right clicking on the open project in project explorer (the menu that contains New, Refactor, Import etc.)

I tried to use

`treeItem.contextMenu("Refactor").menu("Rename...").click(); 

and got WidgetNotFoundException .

help please.

This is currently a known bug in SWTBot...

You cannot access sub-menus of the context menu. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=261360

2 alternatives:

  • ... pressShortcut(SWT.ALT | SWT.SHIFT, 'R')
  • bot.menu("Refactor").menu("Rename...").click();

Hope this helps.

you can use a now native function:

new SWTBotMenu(ContextMenuHelper.contextMenu(bot.tree(), "Refactor", "Rename...")).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