JavaFX警报确定按钮的fx:id是什么?

JavaFX警报确定按钮的fx:id是什么?,java,javafx,testfx,Java,Javafx,Testfx,我使用这个框架来测试我的javaFX应用程序。 我这样测试我的应用程序: @Test public void shouldClickOnDeletMarkerButton() { FxRobot bot = new FxRobot(); bot.robotContext(); bot.clickOn("#deleteMarkerButton"); bot.clickOn("javafx.scene.control.Alert.CANCEL_BUTTON"); //

我使用这个框架来测试我的javaFX应用程序。 我这样测试我的应用程序:

@Test
public void shouldClickOnDeletMarkerButton() {
    FxRobot bot = new FxRobot();
    bot.robotContext();
    bot.clickOn("#deleteMarkerButton");
    bot.clickOn("javafx.scene.control.Alert.CANCEL_BUTTON"); //This doesn't work.
}
我想让他点击的确定按钮,但我还没有找到一个fx:id

JavaFX警报确定按钮的fx:id是什么

编辑:我解决了我的问题,我知道“阅读”,这就足够了:

@Test
public void shouldClickOnDeletMarkerButtonWhenAnyMarkerAsBeenCreated() {
    bot.robotContext();
    bot.clickOn("#deleteMarkerButton");
    bot.clickOn("OK"); //Target text / Target Button / ...
}

fx:id
值指定给元素(如按钮控件的代码中所示)会在文档的命名空间中创建一个变量,您可以从代码中的其他地方引用该变量



fx:id
值指定给元素(如按钮控件的代码中所示)会在文档的命名空间中创建一个变量,您可以从代码中的其他地方引用该变量

@KaluNight,您的解决方案还可以,但只适用于英语本地化

最好使用ids。实际上,
Alert
没有为自己的按钮定义
fx:id
,但我们可以:

Button okButton = (Button) alert.getDialogPane().lookupButton(ButtonType.OK);
okButton.setId("my custom id");

@KaluNight,您的解决方案还可以,但只适用于英语本地化

最好使用ids。实际上,
Alert
没有为自己的按钮定义
fx:id
,但我们可以:

Button okButton = (Button) alert.getDialogPane().lookupButton(ButtonType.OK);
okButton.setId("my custom id");