0

I want to target a specific fxml resource in order to test it using TestFX in junit4. I`m not very good at using java, so I do not know if it's because I typed wrong the path to it.

public class AppTest extends ApplicationTest {

    @Override
    public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("../Input.fxml"));
    stage.setTitle("InputScene Test");
    stage.setScene(new Scene(root));
    stage.show();
    }

    @Before
    public void setUp() throws Exception {
    }

    @After
    public void tearDown() throws Exception {
        FxToolkit.hideStage();
        release(new KeyCode[]{});
        release(new MouseButton[]{});
    }

  @Test
  public void testClickData1() {
        clickOn("#originalTora").write("32");
        clickOn("#originalLda").write("11");
        clickOn("#displacedThreshold").write("23");

  }

My project strucure is:

main/
  java/
    App.java
  resources/
    org.proj2201/
        Input.fxml
test/
  AppTest

I get this when I run it:

org.testfx.api.FxRobotException: the query "#originalTora" returned no nodes.

    at org.testfx.api.FxRobot.queryVisibleNode(FxRobot.java:949)
    at org.testfx.api.FxRobot.pointOfVisibleNode(FxRobot.java:922)
    at org.testfx.api.FxRobot.clickOn(FxRobot.java:630)
    at org.testfx.api.FxRobot.clickOn(FxRobot.java:59)
    at org.testfx.api.FxRobotInterface.clickOn(FxRobotInterface.java:639)
    at AppTest.testClickData1(AppTest.java:38)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

0 Answers0