-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Selenium Testing Tools Cookbook Second Edition
By :
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.
Let's create a set of tests that can handle a confirm box displayed on a page, as follows:
In the testConfirmAccept...
Change the font size
Change margin width
Change background colour