A confirm box is often used to verify or accept something from the user. When a confirm alert is displayed, the user will have to click on either the OK or the Cancel button to proceed, as shown in the following screenshot:
If the user clicks on the OK button, the confirm box returns a true
value response. If the user clicks on the Cancel button, then it returns false
.
A prompt box is often used to accept a value from a user. When a prompt box pops up, the user will have to enter a value and click on either the OK or the Cancel button to proceed, as shown in the following screenshot:
If the user clicks on the OK button, the box returns the input value. If the user clicks on the Cancel button, the box returns null
.
In this recipe, we will handle confirm and prompt boxes using the Selenium WebDriver's Alert
interface.