Forum Discussion
jmcpeek
11 years agoContributor
Manish, this is one of the issues that bothered me as well. I don't like using .exists with mapped objects for that very reason. I've found that the Find method is significantly more reliable. Unfortunately, it doesn't have a built-in wait functionality either. So, I ended up writing my own wait function:
function waitWhile(condition, msg, timeout)
dim t
t = 0
do While eval(condition) and t <= timeout
delaytext = t & " of " & timeout & " seconds passed waiting for " & msg
delay 1000, delaytext
t = t + 1
loop
if t <= timeout then
waitWhile = true
else
waitWhile = false
log.event "Timeout expired waiting for " & msg
end if
end functionAn example call to this would look like:
call waitWhile("aliases.pageObj.find(""name"", ""elementname"", 4, true).exists", "element to appear", 30)So this waits for up to 30 seconds for the object "elementname" to exist within for first 4 tree levels from pageObj. It will also change the indicator to say what it's waiting for (msg) and for how long. In the end, it returns a boolean for whether it hit the timeout period or not.
Hope this helps.