Top Rounds
| We are Hiring! |

_expectPrompt ·

This is a Browser Action API.

A prompt message looks like this: Click for prompt dialog

Javascript calls to prompt(msg) are mocked out by Sahi so that it does not stop the playback.
Sahi by default returns “” if a prompt dialog comes up.
It is possible to make the prompt return the value one wants, by specifying

_expectPrompt(label, value);

before the statement which triggers the prompt dialog.
If there was no expectation set, Sahi will return “”.
It is also possible to get the text of the last occurred prompt dialog using

_lastPrompt();

Syntax:

_expectPrompt(label, value)
The parameters are:

  • label: The visible text on the prompt dialog.
  • value: Value to be filled in the prompt

Example:

<script type="text/javascript"> function showPrompt(){ var t2 = document.f2.t2; t2.value = prompt("Some prompt?"); } </script> <form name="f2"> <input type="button" name="b1" value="Click For Prompt" onclick="showPrompt()"> <input type="text" name="t2"> </form>



_expectPrompt("Some prompt?", "abc") _click(_button("Click For Prompt")); _assertNotNull(_textbox("t2")); _assertEqual("abc", _textbox("t2").value); _assertEqual(_lastPrompt(), "Some prompt?");






---


Top Rounds