Browser Dialogs and Message Boxes

JavaScript applications raise modal dialogs and browser-native message boxes during playback. There are two sides to handle, and they are not the same thing:

These calls block browser execution until the dialog is dismissed. Never leave them in a production or CI script: the run will hang waiting for a person.

API reference

APISignatureWhat it does
alertalert(String: message)Triggers a native alert. Handy as a debugging or logging call — use it to inspect what a variable holds during runtime.
confirmconfirm(String: message)Triggers a native confirm. Call it from CustomJS in action, together with the confirm API.
promptprompt(String: prompt, String: defaultValue)Triggers a native prompt. Call it from CustomJS in action.
printprint()Triggers the native print dialog. Call it from CustomJS in action.

Example — alert as a runtime check

navigateTo("http://www.apple.com");
click(link("ac-gn-link ac-gn-link-iphone"));
click(heading4("typography-headline-reduced"));

var var1 = isVisible(heading4("typography-headline-reduced"));
alert(var1);

if (var1 == true)
{
    click(link("ac-gn-link ac-gn-link-watch"));
}

An alert left in a script stops playback until someone closes it. Remove it before the script is promoted.

Handling a message box raised by the application

TypeBehaviour
AlertInformational dialog, usually dismissed with OK.
ConfirmDialog that expects an accept or dismiss decision — the branch can change the page state.
PromptDialog that may require controlled text before it can be accepted.

Validation workflow

Confirm the dialog is generated by the application, not by the browser as a permission or security prompt. Permission prompts are browser-profile settings, not script steps, and print / navigation dialogs are outside the DOM.

Legacy content

Older Test Designer examples for message boxes were written against previous browser behaviour. Validate any legacy snippet in the current Scenario Editor runtime before reusing it, because native dialog handling depends on the browser and node version in use.

Related: Conditional Functions, Assert Functions.


Revision #2
Created 2026-11-20 17:07:08 UTC by AI_Mananger
Updated 2026-11-20 17:09:59 UTC by AI_Mananger