Open Oliver-Loeffler opened 3 years ago
(Working with v0.0.9)
I think there is only working with selectors where you can, then choosing click coordinates based on it.
Here's what I got right now: Opening the directory dropdown for choosing the directory, then selecting the first location item there
SplitMenuButton chooseDirectory = robot.lookup("#chooser").queryAs(SplitMenuButton.class);
Bounds chooseAbsoluteBounds = chooseDirectory.localToScreen(chooseDirectory.getBoundsInLocal());
// open dropdown with pre-programmed locations
robot.clickOn(chooseAbsoluteBounds.getMaxX() - 10, chooseAbsoluteBounds.getMaxY() - 10);
// choose first item in dropdown (user home)
robot.clickOn(chooseAbsoluteBounds.getMinX() + 20, chooseAbsoluteBounds.getMaxY() + 20);
To then select the first in the list of listed files, I have this code:
private void chooseFirstInListOfFiles(FxRobot robot) {
ListView<?> listOfFiles = robot.lookup("#listOfFiles").queryListView();
// I cannot do this programmatically, it seems
// listOfFiles.getSelectionModel().selectFirst();
// listOfFiles.refresh();
// robot.clickOn(listOfFiles);
clickOnUpperLeftPlusOffset(robot, listOfFiles, 30);
}
private void clickOnUpperLeftPlusOffset(FxRobot robot, Node node, int offset) {
Bounds absoluteBounds = node.localToScreen(node.getBoundsInLocal());
robot.clickOn(absoluteBounds.getMinX() + offset, absoluteBounds.getMinY() + offset);
}
Something like this would be great: If the location menu items had IDs, we could use these selection (rather than absolute coordinates): https://github.com/TestFX/TestFX/issues/662#issuecomment-506352921
Thanks for this very nice idea, I will look into this and see, if I get it working.
It turned out, that the change location (or change directory) functionality implemented is hard to test. Therefore a rework is needed.
Points which turned out problematic: