O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling a prompt box alert

A prompt box is often used to input a value by the user before entering a page. When a prompt box pops up, the user will have to click either on the OK or the Cancel button to proceed after entering an input value, as shown in the following screenshot:

Handling a prompt box alert

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 a prompt box using the Selenium WebDriver's Alert class.

How to do it...

We will create a test that handles a prompt box. We will enter text into the prompt box's input field and later verify if the same value is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required