Skip to main content

Wait Until Image or Text Appears or Vanishes

In many cases, it's necessary to wait for an image or text to appear or vanish on your screen or within a specific region. This ensures that the text or image you are monitoring is correctly detected or removed before proceeding. For example, if you want to click a button within an app, you need to ensure that the button is visible on your screen. Similarly, if you want to proceed only after a loading icon disappears, you need to wait for it to vanish.

Waiting for an Image or Text to Appear

To wait until a template appears, you can use Screen:wait(template: string, timeout: number). Similar to image detection, you need to pass the template as the text or image name.

Equivalent Code

# wait the button appears
Screen:wait('button.jpg', 10000);

Equivalent Block Builder

This macro will wait until "button.jpg" appears on the screen within 10 seconds. If "button.jpg" does not appear within this time, an error will occured.

Waiting for an Image or Text to Appear

To wait until a template vanishes, use Screen:waitVanish(template: string, timeout: number). This function waits for the specified text or image to disappear from the screen.

Equivalent Code

# wait until 'loading_icon.jpg' vanish
Screen:waitVanish('loading_icon.jpg', 10000);

Equivalent Block Builder

This macro will wait until "loading_icon.jpg" disappears from the screen within 10 seconds. If the icon is still visible after this time, an error will occured.