Categories: Selenium Topics

Handling Website Popups In Selenium webdriver

Hello Folks,

I will start series of posts on topic “Handling different types of popup in selenium webdriver”.

What is a popup?

  • A popup is a window/dialog box/alert which appears when you perform some action such as click, load a URL etc.
  • A popup can appear from website, browser and windows.
  • Popup is way of getting/show some information to user such as confirmation, notification etc.

Website Popup:

  • When we open MakeSeleniumEasy URL, you see a dialog boxes within browser asking to subscribe to get post notifications. This type of dialog boxes are generated from website when you load its URL. This is called popup/dialog box generated by URL.
  • You can inspect this popup as you inspect any normal web element.
  • Generally this popup is build using <div> tag.
  • You just need to inspect fields on popup (Email and name is below example) and you can type texts.
  • There is no need of using Alert interface to handle this popup. If you try to use Alert interface to handle this popup, you will get exception NoAlertPresentException.
  • Remember the important point, if you can inspect any popup, you can handle that as you handle any other web element such as text box in selenium webdriver.
  • It has a close button and you can close this popup without performing any action on it.
  • You can not block this popup using popup blocker option of browsers.

 

Java code:

Output:
You can run above program and check. It will print header of pop up and enter details in text boxes.

You can notice, there was no need of any extra knowledge. Just remember, every popup does not require Alert interface to handle it.

Example 2:

When you open TimesOfIndia URL, you are asked for enable new notifications in a popup. You can inspect this and handle it like as a normal button. Try it for better understanding.

 

We will see other types of popups in upcoming posts.

If you have any doubt, feel free to comment below.

If you like my posts, please like, comment, share and subscribe.

#ThanksForReading

#HappySelenium

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Recent Posts

How Much Java Required For Selenium?

"How much Java I need to learn for selenium with Java binding?" is mostly asked question by a Professional who…

2 hours ago

How To Verify If An Input Box Accepts Only Numbers Through Selenium

Hello Guys, You should not be able to type alphabets or special characters in a field which supposed to accept…

4 hours ago

How To Verify Maximum Character Limit of an Input Box Through Selenium

Hello Folks, Recently a guy asked me this question which he was asked in an interview in IBM. What the…

17 hours ago

API Testing Tutorial Part 15 – Sending GET Request With Params in Postman

Hello Folks, As part of our API Testing series, we will see “Sending GET request with params in Postman”. In last…

4 days ago

TestNG Tutorials 62: Dependency in TestNG – Types of Dependencies in TestNG

We have learnt in previous posts regarding establishing relationship between test methods. You can go through them below: Dependency in…

7 days ago

TestNG Tutorials 61: Dependency in TestNG – Creating Dependency Among Test Methods – DependsOnGroup

In previous post, We have learnt to Establish dependency among test methods. In this post, we will see another concept…

7 days ago