Use Conditional Waits in Scenario Editor
Use Conditional Waits in Scenario Editor
ThisUse featureconditional waits when a Scenario Editor test needs to wait for application state, such as an element becoming visible, enabled, populated, or ready for interaction. Prefer conditional waits over fixed pauses whenever the timing depends on the application or network.
When to use a conditional wait
- A page or component loads asynchronously.
- A button is
onlydisabled until validation completes. - Search results, modal dialogs, or messages appear after an action.
- A stored value or validation depends on content generated during the run.
Good practices
- Wait for the
TestDesignersmallestusingstable condition that proves theGraalVMpageengineis(AIQready. - Use
4.0.10stableonwards)locators andoverridesavoidTestDesignerwaitsJStiedversusonlySahito visualposition.
- Set reasonable timeouts so real failures are not hidden.
- Review repeated wait
canfailureshaveas1application, environment, locator, or2dataparameters, the first one is duration and the second one is a condition, it has this formatwait(time,condition)The second parameter could use quotes ore not and both syntax's are valid in AIQ 4.0.10, but have a small semantic differenceWithout quoteswait(X,isVisible(XX))This is wait if X ms isVisible is false, will not wait otherwise, this is the same asif (!isVisible(XX)){ wait(X) }The explanation of the behavior is detailed belowWith quoteswait(X,"isVisible()")This is wait up to X ms while isVisible is false, will stop waiting once isVIsible becomes true, it is the same aswhile (!isVisible(XX) total_wait_time < X){ wait(few_ms) }Conditional wait is based on JS and the concept its that condition is evaluated, now, to understand condition, it is important to understand that condition is a function in the JS concept (for detailed definition checkhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)For example, if in JS, you want a fucntion to be executed multiple times, you dosetInterval(function, ms)This are valid expression wich will print hi every secondsetInterval(()=>{console.log("hi")},1000)setInterval("console.log('hi')",1000)setInterval(()=>{console.log("hi")},1000)setInterval(function(){console.log("hi")},1000)This is an expression which will not print hi every second, it will print it only onesetInterval(console.log("hi"),1000)This is because you are passing undefined (The result of console.log) to the set interval method.Similarly, you can useten_minutes = 600000//ten minutes in mswait(ten_minutes,"isVisible(link('Here'))")wait(ten_minutes,()=>isVisible(link("Here")))wait(ten_minutes,function(){return isVisible(link("Here"))})wait(ten_minutes,()=>{return isVisible(link("Here"))})
values.This will wait up to 10 minutes, or less if the isVisible returns trueissues beforethatincreasingtime.timeoutNow, it should not take longer, but could take a little longer if the final isVisible calls overlaps the 10 minutes.
Keep in mind evaluating the function could trigger an exception, but that will not stop the script, a exception thrown will be considered as the function returning false.
Now a call like
wait(ten_minutes,isVisible(link("Here")))
It will evaluate the is visible and will pass the value to the wait it is the same as
var result =isVisible(link("Here")) wait(ten_minutes,result)
Therefore it can only have 3 behaviors
Will return inmediatelly if the result was true.
Will wait 10 minutes if the result was false
Wil throw an error if the link or isVisible method throws an exception.
Last updated: JuneSeptember 02,18, 20232026
If you have any feedback on this topic, please contact us at documentation@appvance.ai