Using "answerOnNextPrompt" and "assertPrompt" commands in selenium

"answerOnNextPrompt" command

Sometime if you seen , there is display text box with popup message to write some thing in message box. In such popup "answerOnNextPrompt" command is useful to providing answer in popup message. "answerOnNextPrompt" command will type the message whatever you want to type in popup.

Here is one perfect example of "answerOnNextPrompt" command to learn it better. In bellow given example, when user clicking on "Try it" button, It is opening one popup message box with text box. answerOnNextPrompt command will type text "Test" into popup message text box. Please note one thing here - answerOnNextPrompt command is written before click button command which opens the popup. In this way we can predefine the answer what we want to enter into popup text box.

New Test
open =tryjs_prompt
click css=button
assertPrompt Please enter your name

"assertPrompt" Command

"assertPrompt" useful to retrieving the message of the most recent JavaScript question prompt. In above example, it is retrieving the message "Please enter your name" from prompt dialog generated during the previous action

1 comment:

  1. what is the diffrence between assertpromt and assertverification?