final long timeout = System.currentTimeMillis()
+ TimeUnit.SECONDS.toMillis(GrapheneConfigurationContext.getProxy().getWaitGuardInterval());
final long toSleep = Math.min(GrapheneConfigurationContext.getProxy().getWaitGuardInterval() * 100, 200);
while (System.currentTimeMillis() < timeout) {
RequestType requestDone = guard.getRequestDone();
if (!requestDone.equals(RequestType.NONE)) {
if (requestDone.equals(requestExpected)) {
if (requestDone.equals(RequestType.HTTP)) {
waitModel().withMessage("Document didn't become ready").until(documentReady);
}
return result;
} else {
throw new RequestGuardException(requestExpected, guard.getRequestDone());