FAQ: Why Does Selenium Not Work With This Alert?

I received another question about Alerts this morning.

I receive this question frequently enough that I should consider it an FAQ.

So “Why does Selenium not work with my Alert?” or “Why can’t Selenium handle the alert in my application?”

There is an FAQ answer on the Selenium wiki that shows the Alerts API

But that typically doesn’t answer the question because the person asking the question has used the alerts API.

The answer I have given, in every single instance, takes the form “The thing you think is an alert, is not an alert”

The use of the web has changed. HTML has changed. We can now style div elements to look like dialogs and alerts, we can even give them focus and make them modal. That doesn’t mean they fit the definition of an Alert. i.e. something triggered by the JavaScript methods: alert, confirm or prompt


The following are examples of alerts:

With any of the above can you buy propranolol online examples, try and “inspect element” on the alert. You can’t. Because it is an alert.

The following examples are not alerts:

For each of the above, try and “inspect element” and you can. Because it is an HTML div, not an alert.

Live Examples of pseudo-alerts include:

  • those horrible “welcome to our website for the first time will you take our survey about our web site” dialogs
  • “you need to be logged in to see this content” overlays
  • “sign up for my mailing list and I’ll let you see what you came here for” overlay
  • “tweet this and then I’ll let you read it” overlay

Only use the Alert API on things that are Alerts. If you are using the Alert API, and it isn’t working, then the thing you are testing might not be an Alert.

This entry was posted in FAQ, Selenium Simplified Blog. Bookmark the permalink.

3 Responses to FAQ: Why Does Selenium Not Work With This Alert?

  1. thejus says:

    Hello Allen,

    Regarding the maven install. I have followed the steps specified in the maven site and it seems to be working on windows 7. I have added below variables under user section using rapid ee and
    selected the type of M2 and Path variables as expandable string rather than string.

    JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_45
    M2_HOME=C:\Program Files (x86)\Apache Software Foundation\apache-maven-3.1.1


  2. Deric says:

    You just saved my life. I spent hours trying to find out the reason why my tests are failing.
    After I saw your video, was easy to inspect the element and create my flow.

    Thank you so much o///

Leave a Reply

Your email address will not be published. Required fields are marked *