tags:

views:

76

answers:

3

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

+1  A: 

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
how to make when send the command at the right time???
david-shang
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
not page load/unload, oh, it was confirmation windows
david-shang
A: 

prompt error:There were no confirmations
how to send the command at the right time??? selenium default click ok, and do not display the pop-window.

david-shang
A: 

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