Pop Ups in Selenium Python bindings

In HTML pages, we have different kind of pop ups, we will discuss about them in this tutorial. Different popups will have different properties.

Types of Pop Ups :

  • Alert Pop Up
  • Confirmation Pop Up
  • Authentication Pop Up
  • Hidden-Division Pop Up
  • Calendar Pop Up
  • Download Pop UP
  • Upload Pop Up

We have different section for Alert and Confirmation Pop Ups, so in this page we are going to discuss how to handle remaining Pop Ups in selenium python bindings

Authentication Pop Up with Python Selenium

When we open password protected pages, we tend to get Authentication pop up. Authentication pop up will have username and password fields, the UI look of the pop up may vary browser to browser

Visit URL selenium webdriver Auth : https://chercher.tech/auth, site expects you to provide credentials

Credentials :
username - selenium
password - webdriver

Authentication Popup : authentication-pop-up-selenium-webdriver

Properties of the Authentication Pop up :

  • Pop up displayed on Page load
  • We can move the pop up (except in chrome)
  • We cannot inspect the pop up with browser inspection tools like (firepath or edv tools)
  • Look varies from browser to browser

Solution to Authentication Pop Up :

We have to pass the user name and pass word along with url to handle the authentication pop in selenium python. Please find the syntax to pass the username and password

											driver.get("protocol://Usename:Password@URL Address");

Protocols: Http, Https, Ftp,..

To Access the https://chercher.tech/auth page you need to pass username and password like below.


Complete program to handle Authentication popup

import unittest
from selenium import webdriver     
class Test(unittest.TestCase):
    def test_authentication_popup(self):
        driver = webdriver.Chrome(executable_path=r'D:\PATH\chromedriver.exe');
        # open webpage
        # verify the title
        if(driver.title == "Authentication Successful"):
            System.out.println("Test Passed");
            System.out.println("Test failed");          
if __name__ == "__main__":

If login is successful you will see below page on the browser. result-authentication-popup-selenium-webdriver


1. Doesnot work for https protocol
2. It doesnot work when user nam or password contains special characters like : '@' , ':'

Hidden division Pop Up with Python Selenium

Hidden division pop is nothing but html code which is hidden initially, hidden division pop up also known as dialog or overlay.
Overlay is triggered when application user performs certain tasks like clicking a button, submitting the form or on page load...

Examples :

  • Calendar Popups
  • Contact forms
  • Error and success Messages

Properties of Hidden division Pop up :

  • Cannot be moved here and there
  • We can inspect the overlay
  • This is not java Script popup
  • We can resize and customize the content of the pop up
  • If the content is more then the pop up size, pop shows scroll bar
  • When hidden division pop is opened, pop takes the focus from the application.
  • When pop up is closed, focus automatically goes to the application
  • Hidden division popup could be nested i.e a hidden division pop can have another hidden division pop up
  • Hidden division pop can hold other pop ups/ alerts on it.

Handle Hidden division Pop Up :

1. Navigate to : https://chercher.tech/practice/hidden-division-popup
2. Click on View Pop-Up button
3. Application opens a Model

4. Write xpath for the Name text bar : //input[@type='text']
5. Send text for the Name, using sendKyes in selenium.
6. No Special Operation required to handle hidden division popup.

An example program for handling hidden division pop up in selenium python

import unittest
from selenium import webdriver     
class Test(unittest.TestCase):
    def test_authentication_popup(self):
        driver = webdriver.Chrome(executable_path=r'D:\PATH\chromedriver.exe');
        # send text to Name field on overlay
        driver.find_element_by_xpath("//input[@type='text']").send_keys("Hidden Division Text");         
if __name__ == "__main__":

Even though pop up content is present but pop is not present on UI until we click a button, for this reason, it is called as hidden division popup



1. We cannot perform an operation on webpage until we close pop up, if we try to access selenium throws ElementNotClickable exception

About Author

Article is written by Pavan (a) KarthiQ. Well, I am serving notice period in an MNC, Bangalore. I thought to enrich every person knowledge a little, I always have a feeling, when we teach something, we will learn more than what you know. Knowledge is the only thing that doubles when you spend it.

I have also created the reporter for Protractor Jasmine. Use for your projects without any hesitation

You can also share knowledge by Adding a topic here

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions