code: 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;
      }
docs: Create a custom wait mechanism that waits for any background JavaScript to finish
  and verifies a message in the page response.
  
  @param page The current HtmlPage
  @return A boolean value indicating if the response message was found
  @throws InterruptedException