selector.wait

getSelector(id).wait()

or getSelector(id).wait("first")

or getSelector(id).wait(test)

Waits until one of the elements of the selector is selected before evaluating and executing the next commands.

If you call wait("first"), then if an element has already been selected before this command is evaluated, the next commands are evaluated and executed right away. If no element was selected before, the next commands are only evaluated and executed after one element in the selector gets selected.

If you pass a test on an element as an argument, it only evaluates and executes the next commands when an element gets selected while the test is successful. If the test is not successful, it will be checked again upon the next selection.

Example:

[js highlight=”9″ try=”true”]newImage(“square”, “square.png”)
,
newImage(“triangle”, “triangle.png”)
.settings.before( getImage(“square”) )
.print()
,
newSelector(“shapes”)
.settings.add( getImage(“square”) , getImage(“triangle”) )
.wait()[/js]

Adds two images side by side and waits for a click on either one of them.