Skip to content

prompt()

Accept or dismiss a prompt matching a text.
Write into the prompt with accept('Something').

prompt('Message', async () => await accept('something'))
prompt('Message', async () => await dismiss())
// If prompt message is unknown, A RegExp which matches
// the text can be used
prompt(/^Please.+$name/, async () => await accept("NAME"))
// If prompt message is completely unknown, A callback can
// be passed directly, it will get the message, defaultPrompt etc
// as arguments which can be used to make a decision.
prompt(async ({message}) => {
if(message === "Please enter your age?") {
await accept('20')
}
})
// Note: Taiko's `prompt` listener has to be setup before the promt
// popup displays on the page. For example, if clicking on a button
// shows the prompt popup, the Taiko script is
prompt('Message', async () => await accept())
await click('Open Prompt')
NameTypeDescription
messageunknown
callbackfunctionAction to perform. accept/dismiss.
messageOrCallbackstring | RegExp | functionIdentify prompt based on this message, regex or callback.

This API does not return any values.