vendredi 13 décembre 2019

Why isn't the correct TextField being clicked TestFX?

I have 2 text fields inside a button bar. I have given both a fxid. Both Textfields are next to each other.

The left text field has a fx:id newCol While the texfield to it's right has a fx:id of Name

I am doing the following test

 @Test
    public void ensureNewColIsCreated() {
        clickOn("#newCol").write("To do list!");
        sleep(2000);
        clickOn("#Name").write("New page");
        sleep(2000);
    }

Expected outcome should be it first goes to the left textfield, rights the command. It should then type the another message into the right textfield.

However what happens instead is after the first message is typed into the left Textfield, the next message which should be typed into the right textfield also gets typed into the left texfield. Right before the second message the mouse does move ever so slightly to the right.

Now when I swap the two lines as shown below

 @Test
    public void ensureNewColIsCreated() {
        clickOn("#Name").write("To do list!");
        sleep(2000);
        clickOn("#newCol").write("New page");
        sleep(2000);
    }

The message should be typed into the right textfield first. However, it is still being typed into the left textfield. Both messages are.

If i just do the following without specifying the fx:id, it still types into the left textfield

@Test
    public void ensureNewColIsCreated() {
        write("Test");
    }

I'm guessing I am using testfx horribly wrong or something because I am very new to it and it is my first time doing any kind of testing. If someone can help me out that would be great.

Aucun commentaire:

Enregistrer un commentaire