public static boolean waitForPageResponse ( HtmlPage page , String responseMessage ) throws InterruptedException { int i = 0 ; boolean isTextFound = false ; while ( ! isTextFound && i < 5 ) { isTextFound = page . asText ( ) . contains ( responseMessage ) ; i ++ ; Thread . sleep ( 1000 ) ; Log . info ( c , "waitForPageResponse" , "Waiting for: " + responseMessage + " isTextFound: " + isTextFound + " i: " + i ) ; } return isTextFound ; }
Create a custom wait mechanism that waits for any background JavaScript to finish and verifies a message in the page response .