0

Using Awaitility in Testfx FxRobot framework - Unable to wait till node visible Everytime when fxid element is not shown on UI polling is not happening it is throwing node not found. Another thing is to save the captured snapshot path I am not getting how to use Image and how to provide path in catch. Please help.

public <T extends Node> TextField lookupByIdTextField( String controlId,FxRobot robot) {
    try {
        with()
        .await()
        .pollDelay(2,  TimeUnit.SECONDS)
        .atMost(60, TimeUnit.SECONDS)
        .until(() -> (robot.lookup(controlId).queryAs(TextField.class))!= null);
    }catch(Exception e)
    {
        logger.error(e.getMessage());
        Rectangle2D r=new Rectangle2D(0, 0, 600, 700);
        Capture c=robot.capture(r);
        c.getImage();


    }

    return robot.lookup(controlId).queryAs(TextField.class);

}
Nee
  • 11
  • 3
  • How does `await()` work? Does it block the calling thread? If so, then you're likely blocking the _JavaFX Application Thread_ which means nothing related to the UI can progress until the thread is allowed to continue. – Slaw Mar 31 '21 at 10:29
  • https://www.baeldung.com/awaitlity-testing @Slaw I dont have much clarity .. I am looking for solution to wait and avoid thread.sleep everytime.. – Nee Mar 31 '21 at 10:56
  • Is there any reason why you are not using this: https://github.com/TestFX/TestFX/blob/master/subprojects/testfx-core/src/main/java/org/testfx/util/WaitForAsyncUtils.java#L318 – trisek Nov 02 '21 at 14:30

0 Answers0