O'Reilly logo

Learning Selenium Testing Tools with Python 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

Working with alerts and pop-up windows

Developers use JavaScript alerts or model dialogs to inform users about validation errors, warnings, to give a response for an action, accept an input value, and more. In this section, we will see how to handle alerts and pop-up windows with Selenium.

Understanding the Alert class

Selenium WebDriver provides the Alert class to handle JavaScript alerts. The Alert class contains methods for accepting, dismissing, inputting, and getting text from alerts.

Properties of the Alert class

The Alert class implements the following property:

Property/attribute

Description

Example

text

This gets text from the alert window

alert.text

Methods of the Alert class

The Alert class implements the following methods:

Method ...

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