Taiko
Documentation

Home / API Reference

prompt

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

Examples

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')

Parameters


messageOrCallback

Identify prompt based on this message, regex or callback.


callback

Action to perform. accept/dismiss.


Returns

This API does not return any values