REALLY waiting for element to load

i disconnected the network and then click on a button so that the spinner will be visible for ever.

1 Like

You can add breakpoints in the code where you are expecting the loader.

It’s so simple… :grinning: Thanks @Manu_Mahendran !:clap:

1 Like

You are welcome

I added a few lines to the script conceived above (all verifyElement* and waitForElement* variants are called and the click is included inside the function now), but often I still get the messages

testObject is ready

and

Unable to click on object ...

at the same time.

	def smartWaitClickableAndClick(TestObject testObject, int waitTime){
	for (int j = 0; j <= waitTime; j++) {
		if(!(
			WebUI.verifyElementClickable(testObject, FailureHandling.OPTIONAL)
			&& WebUI.verifyElementVisible(testObject, FailureHandling.OPTIONAL)
			&& WebUI.verifyElementPresent(testObject, 5, FailureHandling.OPTIONAL))
		){
			WebUI.comment('Element ' + testObject.toString() + ' is not ready.')
			WebUI.delay(1)
			//continue
		}else{
			WebUI.comment(testObject.toString() + ' is ready')
			WebUI.waitForElementPresent(testObject, 5)
			WebUI.waitForElementVisible(testObject, 5)
			WebUI.waitForElementClickable(testObject, 5)
			WebUI.click(testObject)
			break
		}
		if(j==waitTime){
			KeywordUtil.markFailed('Element ' + testObject.toString() + ' was never found')
			break
		}
	}
}