public static object waitForJsVariable(this WatiN_IE watinIe, string jsCommand, int sleepMiliseconds, int maxSleepTimes) { "[WatiN_IE][waitForJsVariable] trying to find jsObject called '{0}' for {1} x {2} ms".info(jsCommand, maxSleepTimes, sleepMiliseconds); watinIe.setJsObject(null); for (var i = 0; i < maxSleepTimes; i++) { if (watinIe.doesJsObjectExists(jsCommand)) { var jsObject = watinIe.getJsObject(jsCommand); "[watinIe][waitForJsVariable] got value: {0} ({1} tries)".info(jsObject, i); return(jsObject); } watinIe.sleep(500, false); } "[WatiN_IE][waitForJsVariable] didn't find jsObject called '{0}' after {1} sleeps of {2} ms".error(jsCommand, maxSleepTimes, sleepMiliseconds); return(null); }