diff --git a/src/main/java/org/robotframework/swing/keyword/tree/TreeNodePopupKeywords.java b/src/main/java/org/robotframework/swing/keyword/tree/TreeNodePopupKeywords.java index 2687ea9e..1421e44e 100644 --- a/src/main/java/org/robotframework/swing/keyword/tree/TreeNodePopupKeywords.java +++ b/src/main/java/org/robotframework/swing/keyword/tree/TreeNodePopupKeywords.java @@ -48,17 +48,23 @@ public void selectFromTreeNodePopupMenuInSeparateThread(String identifier, Strin } @RobotKeyword("Invokes a menu action on all the selected tree nodes.\n" - + "Does not wait for a result.\n" + + "If ``checkItemIsEnabled`` is set to False, it does not wait for a result, " + + "so even if the menu item is disabled, the keyword does not fail .\n " + + "By default `checkItemIsEnabled` is True. \n" + "Separator for items is ``|``.\n\n" + "Examples:\n" - + "| `Select Tree Node` | myTree | Root|Folder1 |\n" + + "| `Select Tree Node` | myTree | Root|Folder1 | true |\n" + "| `Select Tree Node` | myTree | Root|Folder2 |\n" + "| `Select From Popup Menu On Selected Tree Nodes` | myTree | Remove | ") - @ArgumentNames({"identifier", "menuPath"}) - public void selectFromPopupMenuOnSelectedTreeNodes(String identifier, String menuPath) { + @ArgumentNames({"identifier", "menuPath", "checkItemIsEnabled=True"}) + public void selectFromPopupMenuOnSelectedTreeNodes(String identifier, String menuPath, Boolean checkItemIsEnabled) { JPopupMenuOperator popupOperator = treeOperator(identifier).createPopupOperatorOnSelectedNodes(); - popupOperator.pushMenuNoBlock(menuPath, new EqualsStringComparator()); - SwingWaiter.waitToAvoidInstability(300); + if (checkItemIsEnabled == Boolean.TRUE) { + popupOperator.pushMenu(menuPath, new EqualsStringComparator()); + } else { + popupOperator.pushMenuNoBlock(menuPath, new EqualsStringComparator()); + SwingWaiter.waitToAvoidInstability(300); + } } @RobotKeyword("Fails if given popup menu item is disabled.\n\n" diff --git a/src/test/resources/robot-tests/tree.robot b/src/test/resources/robot-tests/tree.robot index 8d2df37d..04139778 100644 --- a/src/test/resources/robot-tests/tree.robot +++ b/src/test/resources/robot-tests/tree.robot @@ -477,6 +477,12 @@ Get Current Selection Paths ${selected_elements} = getSelectionPaths ${treeName} listsShouldBeEqual ${selected_elements} ${expected_elements} +Select From Popup Menu On Selected Tree Nodes Check Menu Item + [Setup] resetNodes + selectNodes + selectFromPopupMenuOnSelectedTreeNodes ${treeName} Disabled menuitem False + Run Keyword And Expect Error Menu pushing: (JMenuItem with text "Disabled menuitem") selectFromPopupMenuOnSelectedTreeNodes ${treeName} Disabled menuitem True + *** Keywords *** keywordShouldFailBecauseContextIsIllegal [Arguments] ${keyword} @{arguments}