Complete Automation Testing Tutorials

JavaScript has three kind of popup boxes: Alert box, Confirm box, and Prompt box.

Let's try to see all the three examples below


Java Script Alert Box

When an alert box pops up, user have to click "OK" button to proceed.


Click the button to display an alert box:

Java Script Confirm Box

When a confirm box pops up, user can click "OK" or "Cancel" to proceed.

Box returns true, if the user clicks "OK" and box returns false if user clicks "Cancel"

Click the button to display an confirm box:

Java Script Alert Box

When a prompt box pops up, user can click "OK" or "Cancel" to proceed

If the user clicks "OK" after entering the input value, it will return value as Output. If the user clicks "Cancel" the box returns nothing.

Click below button for prompt box.