testFX in javaFX unable to test fxid tag

0

I am trying to write junit for JavaFX. I am using testFx.

in my fxml file:

<Text fx:id="actiontarget"
       GridPane.columnIndex="1" GridPane.rowIndex="6"/>

I have a functionality in my controller class:


    @FXML protected void handleSubmitButtonAction(ActionEvent event) {
    actiontarget.setText("Sign in button pressed");

Now I when I am writing test class :

@Test
  public void testEnglishInput () {
      // when:
      clickOn(".button");

      // then:
      verifyThat("#actiontarget", hasText("Sign in button pressed"));
  }

Its showing an error

java.lang.AssertionError: 
Expected: Labeled has text "Sign in button pressed"
     but: was a javafx.scene.text.Text (<Text[id=actiontarget, text="Sign in button pressed", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=12.0], fontSmoothingType=GRAY, fill=0x000000ff]>)

I want to know how I can try testing the text value? I tried #actiontarget.text, that also not working. I am new to JavaFX and TestFx. Please help!

java
javafx
junit
testfx
asked on Stack Overflow Jul 13, 2020 by Tech Geek

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0