Refresh Page until element appears (or doesnt)

Hello jdm,

this code should work for you - I used while loop instead of if-else statement.

long timestart// timeout set to 300 secondsint timeout = 300WebUI.waitForPageLoad(30)timestart = System.currentTimeMillis() / 1000L// while element not present, click refresh and wait 30 seconds and check timeoutwhile (!WebUI.verifyElementPresent(findTestObject("Objects/Test Object"), 1, FailureHandling.OPTIONAL)) {	long currenttime = System.currentTimeMillis() / 1000L	// if timeout is reached, mark test failed	if(currenttime > timestart + timeout) {		KeywordUtil.markFailed("Timeout reached.")	}	WebUI.click(findTestObject("Objects/Refresh Button"))	WebUI.delay(30)}// click object as soon as you're outside of the loopWebUI.click(findTestObject("Objects/Test Object"))

3 Likes