protected JMenuBarOperator menubarOperator() { JMenuBarOperator menuBarOperator = new JMenuBarOperator((ContainerOperator) Context.getContext()); menuBarOperator.setComparator(comparator); return menuBarOperator; }
@RobotKeyword("Selects all items from the menu of the window that was opened first and returns their names.\n\n" + "Example:\n" + "| @{mainMenuItemNames}= | `Get Main Menu Item Names` |\n" + "| `Should Contain` | @{mainMenuItemNames} | File |\n") public List<String> getMainMenuItemNames() { JMenuBarOperator mbo = menubarOperator(); List<String> returnable = new ArrayList<String>(); for (int index = 0; index < mbo.getMenuCount(); index++) { returnable.add(mbo.getMenu(index).getText()); } return returnable; }
private void closeMenu() { menubarOperator().pressMouse(); }
private static void closeToolbar(String menu){ MainWindowOperator mainWindow = MainWindowOperator.getDefault(); JMenuBarOperator menuBar = new JMenuBarOperator(mainWindow.getJMenuBar()); JMenuItemOperator menuItem = menuBar.showMenuItem(menu,"|"); if(menuItem.isSelected()) menuItem.push(); else { menuItem.pushKey(java.awt.event.KeyEvent.VK_ESCAPE); mainWindow.pushKey(java.awt.event.KeyEvent.VK_ESCAPE); } }
private MenuElement[] getSubElements(String path) { MenuElement[] subElements = menubarOperator().showMenuItem(path).getSubElements(); if (subElements.length == 0) { return new MenuElement[0]; } return subElements[0].getSubElements(); } }
@RobotKeyword("Selects an item from the menu of the window that was opened first and returns it's name.\n\n" + "Example:\n" + "| ${mainMenuItemName}= | `Get Main Menu Item Name` | 0 |\n" + "| `Should Be Equal` | File | ${mainMenuItemName} |\n") @ArgumentNames({"index"}) public String getMainMenuItemName(String index) { if (!isIndex(index)) { throw new UnsupportedOperationException("The argument must be an index."); } return menubarOperator().getMenu(asIndex(index)).getText(); }
private static void closeToolbar(String menu){ MainWindowOperator mainWindow = MainWindowOperator.getDefault(); JMenuBarOperator menuBar = new JMenuBarOperator(mainWindow.getJMenuBar()); JMenuItemOperator menuItem = menuBar.showMenuItem(menu,"|"); if(menuItem.isSelected()) menuItem.push(); else { menuItem.pushKey(java.awt.event.KeyEvent.VK_ESCAPE); mainWindow.pushKey(java.awt.event.KeyEvent.VK_ESCAPE); } }
protected JMenuItemOperator showMenuItem(final String path) { JMenuItemOperator menuItemOperator = menubarOperator().showMenuItem(path); menuItemOperator.setComparator(comparator); SwingWaiter.waitToAvoidInstability(200); menuItemOperator.grabFocus(); SwingWaiter.waitToAvoidInstability(200); return menuItemOperator; }