6161import java .util .regex .Matcher ;
6262import java .util .regex .Pattern ;
6363
64+ import static javafxlibrary .matchers .ExtendedNodeMatchers .hasValidCoordinates ;
6465import static javafxlibrary .utils .TestFxAdapter .objectMap ;
6566import static javafxlibrary .utils .TestFxAdapter .robot ;
6667import static org .testfx .matcher .base .NodeMatchers .*;
@@ -76,18 +77,16 @@ public static Node waitUntilExists(String target) {
7677
7778 public static Node waitUntilExists (String target , int timeout , String timeUnit ) {
7879 RobotLog .trace ("Waiting until target \" " + target + "\" becomes existent, timeout="
79- + Integer . toString ( timeout ) + ", timeUnit=" + timeUnit );
80+ + timeout + ", timeUnit=" + timeUnit );
8081
8182 try {
82-
83- WaitForAsyncUtils .waitFor ((long ) timeout ,
84- getTimeUnit (timeUnit ),
85- () -> Matchers .is (isNotNull ()).matches (createFinder ().find (target )));
86- return createFinder ().find (target );
87-
83+ WaitForAsyncUtils .waitFor ((long ) timeout , getTimeUnit (timeUnit ), () -> createFinder ().find (target ) != null );
84+ Node node = createFinder ().find (target );
85+ WaitForAsyncUtils .waitFor ((long ) timeout , getTimeUnit (timeUnit ), () -> hasValidCoordinates (node ));
86+ return node ;
8887 } catch (TimeoutException te ) {
8988 throw new JavaFXLibraryNonFatalException ("Given element \" " + target + "\" was not found within given timeout of "
90- + Integer . toString ( timeout ) + " " + timeUnit );
89+ + timeout + " " + timeUnit );
9190 } catch (Exception e ) {
9291 RobotLog .trace ("Exception in waitUntilExists: " + e + "\n " + e .getCause ().toString ());
9392 throw new JavaFXLibraryNonFatalException ("waitUntilExist failed: " + e );
0 commit comments