I'm scratching my head here trying to get my TestFX robot to click on a Menu
and then a MenuItem
.
None of the above classes derive from Node
so I cannot use fxRobot.clickOn(Node node)
.
Does anyone else have an idea of how to accomplish this? Besides simply using a TextMatcher, which searches through the whole scope.
Example of MenuBar with a menu:
<MenuBar fx:id="mainMenuBar">
<menus>
<Menu mnemonicParsing="false" style="-fx-font-weight: bold;" text="MainMenu">
<items>
<MenuItem mnemonicParsing="false" style="-fx-font-weight: normal;" text="About" />
<MenuItem mnemonicParsing="false" style="-fx-font-weight: normal;" text="Exit" />
</items>
</Menu>
How would I achieve a robot clicking on the top Menu
(preferrably by the visible text of the menu) and the the menuItem inside (also preferrably selected by the visual text)
Example of ChoiceBox:
<ChoiceBox fx:id="myChoices" />
It's items are dynamically populated from my controller:
@FXML private ChoiceBox myChoices;
@FXML
public void initialize() {
List<String> items = ItemsRepo.getItems();
myChoices.setItems(FXCollections.observableArrayList(items))
}
I could first click the choiceBox via it's fx:id
. But how would I then select one of it's items? Preferably from the items visible text. The items texts could interfer with other texts inside the application. So I want to make sure I click one of the choicebox items, not some other text.
Regards