Skip to main content

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

  1. Wait for the TestDesignersmallest usingstable condition that proves the GraalVMpage engineis (AIQready.
  2. Use 4.0.10stable onwards)locators and overridesavoid TestDesignerwaits JStied versusonly Sahito visual

    position.

  3. Set reasonable timeouts so real failures are not hidden.
  4. Review repeated wait canfailures haveas 1application, environment, locator, or 2data parameters, the first one is duration and the second one is a condition, it has this format
    wait(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 difference

    Without quotes
    wait(X,isVisible(XX)) 

    This is wait if X ms isVisible is false, will not wait otherwise, this is the same as

    if (!isVisible(XX)){
      wait(X)
    }

    The explanation of the behavior is detailed below

    With quotes
    wait(X,"isVisible()") 

    This is wait up to X ms while isVisible is false, will stop waiting once isVIsible becomes true, it is the same as

    while (!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 check https://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 do

    setInterval(function, ms)

    This are valid expression wich will print hi every second

    setInterval(()=>{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 one

    setInterval(console.log("hi"),1000)

    This is because you are passing undefined (The result of console.log) to the set interval method.

    Similarly, you can use

    ten_minutes = 600000//ten minutes in ms
    wait(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"))})

    This will wait up to 10 minutes, or less if the isVisible returns trueissues before thatincreasing time.timeout Now, it should not take longer, but could take a little longer if the final isVisible calls overlaps the 10 minutes.

    values.

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