* @return the menu item with the specified text
* @throws WidgetNotFoundException if the menuItem could not be found
* @since 1.0
*/
public SWTBotMenu menuItem(String menuItem) throws WidgetNotFoundException {
EventContextMenuFinder menuFinder = new EventContextMenuFinder();
try {
menuFinder.register();
log.debug(MessageFormat.format("Clicking on {0}", this)); //$NON-NLS-1$
assertEnabled();
notify(SWT.MouseEnter);
notify(SWT.MouseMove);
notify(SWT.Activate);
notify(SWT.FocusIn);
notify(SWT.MouseDown);
notify(SWT.MouseUp);
notify(SWT.Selection, arrowEvent());
notify(SWT.MouseHover);
notify(SWT.MouseMove);
notify(SWT.MouseExit);
notify(SWT.Deactivate);
notify(SWT.FocusOut);
log.debug(MessageFormat.format("Clicked on {0}", this)); //$NON-NLS-1$
Matcher<? extends Widget> matcher = withMnemonic(menuItem);
List<?> findMenus = menuFinder.findMenus(new SWTBot().activeShell().widget, matcher, true);
log.debug(findMenus);
if (findMenus.isEmpty())
throw new WidgetNotFoundException("Could not find a menu item"); //$NON-NLS-1$
return new SWTBotMenu((MenuItem) findMenus.get(0), matcher);
} finally {
menuFinder.unregister();
}
}