How to test javascript dialogs ( alert, confirm, prompt )

Updated 2 weeks ago by CST

Javascript dialogs ( alert, confirm and prompt ) are not part of the browser's DOM, so their actions and events cannot be recorder or executed in a regular way, but there are a series of special commands to manage the three types of javascript dialogs:


alert() dialogs have a single "ok" button, and no choice is given. Right after the action ( clicking on a link or a button ) that triggers an alert, you need to acknowledge and close it... you can do this with the command:

clickcopado=button:Show an alert

The parameter "*" means "any text", and will match any text shown in the dialog.


confirm() dialogs have two buttons, typically ok and cancel.

If you need to make a choice between the two actions, you need to add one of the following commands before the action that will open a dialog, and acknowledge the confirm() dialog afterwards:

clickcopado=button:Show a confirm

The choice is optional... you can omit chooseOkOnNextConfirmationchooseCancelOnNextConfirmation and by default the dialog will be closed by clicking OK.


prompt() dialogs have two buttons, typically ok and cancel, and the user can enter some text in it.

In order to enter the text, you need to add answerOnNextPrompt before the action that will open it.

clickcopado=button:Enter a number

How did we do?