Home > Automation Testing > Protractor > Handling Popups using protractor

Handling Popups using protractor

Identify or handle javascript popup/alert using protractor in automation.

Javascript popup cannot be inspected. We don’t get html for javascript popup. So we cannot find element and it is not possible to perform operation based on web element. There are different types of java script popups. Those are Simple alert, Confirmation alert and Prompt alert.

Simple alert contains only Ok button, we can use accept() method to click on ok.

Confirmation alert contains Ok and Cancel buttons, we can use accept() button to click on Ok and dismiss() method to click on cancel.

Prompt alert contains input box, Ok and Cancel buttons. To input some text we can use sendKeys() method

Use accept method to press ok/submit button on displayed popup.

Dismiss javascript popup:

Get text of javascript popup:

Send Keys to javascript popup:

Handling child browser popup in protractor:

Child browser is popup having many web elements. Elements inside the popup can be inspected and elements can be identified by find element and any actions can be performed on those elements.

Before performing any actions on those web elements we need to switch into popup. To perform window switch we can use window handles.

This code switches into child browser popup:

 

This Article is TAGGED in , , . BOOKMARK THE permalink.

Avatar photo
Amit Bharamasali
Automation Software Test Engineer. Skills: Manual Testing, Selenium, Java, Protractor, JavaScript, Katalon Studio, Groovy, Appium, Sahi, Sahi Script and UI/UX testing.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">