2

Using Selenium, how can I get the contents of a JavaScript confirmation prompt?

Screenshot of the prompt: http://www.freeimagehosting.net/image.php?a296dd8a59.png

Community
  • 1
  • 1
david-shang
  • 101
  • 2
  • 3
  • 10

2 Answers2

3

Your screenshot shows a JavaScript confirmation prompt. You can use the *Confirmation commands, such as:

verifyConfirmation | The changes you made will be lost
assertConfirmation | The changes you made will be lost

By default Selenium will accept the confirmation, however to influence this use the chooseCancelOnNextConfirmation or chooseOkOnNextConfirmation commands.

With Selenium RC you'd use getConfirmation.

Selenium reference for above commands:

Dave Hunt
  • 8,191
  • 4
  • 38
  • 39
  • You need to make sure you use the command at the correct time. It looks like at the time your command is sent the confirmation prompt is not present. What triggers the prompt? If it's page load/unload then Selenium might not be able to handle it. – Dave Hunt Jul 01 '10 at 08:42
0

You need to check if the popup is alert,confirmation or prompt. All three has different functions. Check the source for the same and use the appropriate command in RC or IDE

Rajasankar
  • 928
  • 1
  • 19
  • 41