SlideShare a Scribd company logo
PopUp handling in Selenium 2.x

                By
           Aparna Naik
       www.DestinationQA.com




                                    1
            www.destinationqa.com
Agenda
Different types of PopUps

Handling JavaScript PopUps

Webdriver Alerts API

Java AWT Robot class to handle windows popups

Other ways to handle Popups



                                                2
                 www.destinationqa.com
PopUps
Usually, a web application can generate following types of popup windows:

JavaScript PopUps         Browser PopUps           Native OS PopUps




 JavaScript popup windows are generated by the web application code.
             Hence they can be controlled by the browser.




Native Popups like the File Upload / Download windows call the operating
system’s native interface. Hence once they are opened, the browser has
                          little control over them.



                                                                            3
                          www.destinationqa.com
Handling JavaScript PopUps

Selenium provides an API to handle
JavaScript PopUps.
  Alert alert = driver.switchTo().alert();



The Alert API allows various operations
on the Alert object:
  accept(), dismiss(), getText(),sendKeys()




                                              4
                 www.destinationqa.com
Handling Browser and Native OS
PopUps

As Selenium does not provide support to
these kind of Popups, we need to
explore other options. There are several
ways to handle such popups like:
• Setup Browser Profiles
• Use Java.awt.Robot toolkit
• Use external program like AutoIT

                                           5
              www.destinationqa.com
Setup Browser Defaults
A useful way to handle popups is to set the
Browser Defaults to disable popups wherever
possible. This can usually be done for popups
which ask whether a File should be
downloaded.




                                                6
                  www.destinationqa.com
Handling File Download windows
When a file is to be downloaded, browser will
ask you where the file is to be saved.
Usually, this option can also be set to a default
location to avoid this popup.




                                                    7
                   www.destinationqa.com
Setup a Browser Profile
• Selenium opens up its own profile with
   default settings each time a driver is
   initialized. Hence the option settings will
   not persist.
• To avoid this, we can set up a profile for
   Selenium to use, where these
   preferences are set as required.
Selenium Code to Initialize Profile:
 ProfilesIni allProfiles = new ProfilesIni();
 FirefoxProfile profile =
 allProfiles.getProfile("Selenium");


                                                 8
                  www.destinationqa.com
The Java AWT Robot Class

This class can generate native input events to the underlying
OS using the Keyboard and Mouse Interfaces

Methods in this class can be effectively used to do the minimal
interaction with native popups occurring in Web Applications.

Some of the useful API provided are:

 • keyPress();
 • mousePress();
 • Mousemove();

                                                                  9
                       www.destinationqa.com
The Java AWT Robot Class Contd..

Although the Robot Class can be used to interact
with PopUps, there are some limitations like:

• All interactions happen using either
  Keyboard events or screen
  coordinates.
• Keyboard events handle 1 character at
  a time (no Strings)
• Cannot capture object properties using
  this class.

                  www.destinationqa.com            10
Using External Programs (AutoIT)

AutoIT is a tool that can automate the
Windows GUI.
AutoIT generates an executable file that
can be called from the Selenium script.
AutoIT Code Example:
 WinWaitActive("Choose File to Upload")
      Send("D:test.jpeg")
      Send("{ENTER}")

                 Download AutoIT at:
         http://www.autoitscript.com/site/autoit/downloads/


                      www.destinationqa.com                   11
Thank You…
Aparna Naik
Email: naik.aparna@destinationqa.com
Tel: +91 99233 50980




                                               12
                       www.destinationqa.com

More Related Content

What's hot (20)

PPTX
VorlonJS
Fabrício Catae
 
PPTX
Selenium introduction
Deepak Kumar Digar
 
PPTX
Session 01 - Introduction to Selenium - Part 2
SiddharthSelenium
 
PPTX
Selenium presentation
shivani thakur
 
PPTX
1 java fundamental KSHRD
Tola Meng
 
PPTX
Selenium - Introduction
Sachin-QA
 
PDF
Selenoid: browsers in containers
Ivan Krutov
 
PPT
Selenium By Pravin Mishra
Pravin Mishra
 
PDF
Scalable Selenium cluster: up and running
Ivan Krutov
 
PPSX
Selenium RC
ANKUR-BA
 
PPTX
Selenium
Andrew Krug
 
PPTX
Using protractor to build automated ui tests
🌱 Dale Spoonemore
 
PDF
Mobile automation: a three act tragedy
Ivan Krutov
 
PDF
Enyo Hackathon Presentation
Ben Combee
 
PDF
Vagrant development environment
Hiraq Citra M
 
PDF
How to Handle Multiple Windows in Selenium Webdriver | Edureka
Edureka!
 
PDF
BeEF: The Browser Exploitation Framework
awiasecretary
 
PPTX
Automation Tools Overview
Sachin-QA
 
PPTX
Appium Meetup #2 - Mobile Web Automation Introduction
snevesbarros
 
VorlonJS
Fabrício Catae
 
Selenium introduction
Deepak Kumar Digar
 
Session 01 - Introduction to Selenium - Part 2
SiddharthSelenium
 
Selenium presentation
shivani thakur
 
1 java fundamental KSHRD
Tola Meng
 
Selenium - Introduction
Sachin-QA
 
Selenoid: browsers in containers
Ivan Krutov
 
Selenium By Pravin Mishra
Pravin Mishra
 
Scalable Selenium cluster: up and running
Ivan Krutov
 
Selenium RC
ANKUR-BA
 
Selenium
Andrew Krug
 
Using protractor to build automated ui tests
🌱 Dale Spoonemore
 
Mobile automation: a three act tragedy
Ivan Krutov
 
Enyo Hackathon Presentation
Ben Combee
 
Vagrant development environment
Hiraq Citra M
 
How to Handle Multiple Windows in Selenium Webdriver | Edureka
Edureka!
 
BeEF: The Browser Exploitation Framework
awiasecretary
 
Automation Tools Overview
Sachin-QA
 
Appium Meetup #2 - Mobile Web Automation Introduction
snevesbarros
 

Similar to Selenium Webdriver pop up handling (20)

PDF
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
PDF
JAVA INTRODUCTION
Prof Ansari
 
PDF
JAVA INTRODUCTION
Prof Ansari
 
PDF
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
AnanthReddy38
 
PPT
Steps to write Selenium
Rohit Thakur
 
PDF
Selenium Full Material( apprendre Selenium).pdf
Sdiri Ahmed
 
PPTX
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
AnanthReddy38
 
PDF
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
PPTX
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
irpycon
 
PDF
Web Test Automation Framework - IndicThreads Conference
IndicThreads
 
PDF
Selenium&scrapy
Arcangelo Saracino
 
PPT
Stepin evening presented
Vijayan Reddy
 
PPT
Selenium using C# by Yogesh Kumar
Software Testing Board
 
PDF
Selenium for Tester.pdf
RTechRInfoIT
 
PDF
Selenium Tutorial
prad_123
 
PPSX
Selenium WebDriver
Rajathi-QA
 
DOCX
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
PPSX
JAVA.ppsx java code java edv java development
wannabekrishna0
 
PPTX
Test automation using selenium
Cynoteck Technology Solutions Private Limited
 
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
jamescantor38
 
JAVA INTRODUCTION
Prof Ansari
 
JAVA INTRODUCTION
Prof Ansari
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
AnanthReddy38
 
Steps to write Selenium
Rohit Thakur
 
Selenium Full Material( apprendre Selenium).pdf
Sdiri Ahmed
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
AnanthReddy38
 
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
irpycon
 
Web Test Automation Framework - IndicThreads Conference
IndicThreads
 
Selenium&scrapy
Arcangelo Saracino
 
Stepin evening presented
Vijayan Reddy
 
Selenium using C# by Yogesh Kumar
Software Testing Board
 
Selenium for Tester.pdf
RTechRInfoIT
 
Selenium Tutorial
prad_123
 
Selenium WebDriver
Rajathi-QA
 
Class notes(week 10) on applet programming
Kuntal Bhowmick
 
JAVA.ppsx java code java edv java development
wannabekrishna0
 
Test automation using selenium
Cynoteck Technology Solutions Private Limited
 
Ad

Recently uploaded (20)

PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Français Patch Tuesday - Juillet
Ivanti
 
PPTX
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Français Patch Tuesday - Juillet
Ivanti
 
Extensions Framework (XaaS) - Enabling Orchestrate Anything
ShapeBlue
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
CloudStack GPU Integration - Rohit Yadav
ShapeBlue
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Ad

Selenium Webdriver pop up handling

  • 1. PopUp handling in Selenium 2.x By Aparna Naik www.DestinationQA.com 1 www.destinationqa.com
  • 2. Agenda Different types of PopUps Handling JavaScript PopUps Webdriver Alerts API Java AWT Robot class to handle windows popups Other ways to handle Popups 2 www.destinationqa.com
  • 3. PopUps Usually, a web application can generate following types of popup windows: JavaScript PopUps Browser PopUps Native OS PopUps JavaScript popup windows are generated by the web application code. Hence they can be controlled by the browser. Native Popups like the File Upload / Download windows call the operating system’s native interface. Hence once they are opened, the browser has little control over them. 3 www.destinationqa.com
  • 4. Handling JavaScript PopUps Selenium provides an API to handle JavaScript PopUps. Alert alert = driver.switchTo().alert(); The Alert API allows various operations on the Alert object: accept(), dismiss(), getText(),sendKeys() 4 www.destinationqa.com
  • 5. Handling Browser and Native OS PopUps As Selenium does not provide support to these kind of Popups, we need to explore other options. There are several ways to handle such popups like: • Setup Browser Profiles • Use Java.awt.Robot toolkit • Use external program like AutoIT 5 www.destinationqa.com
  • 6. Setup Browser Defaults A useful way to handle popups is to set the Browser Defaults to disable popups wherever possible. This can usually be done for popups which ask whether a File should be downloaded. 6 www.destinationqa.com
  • 7. Handling File Download windows When a file is to be downloaded, browser will ask you where the file is to be saved. Usually, this option can also be set to a default location to avoid this popup. 7 www.destinationqa.com
  • 8. Setup a Browser Profile • Selenium opens up its own profile with default settings each time a driver is initialized. Hence the option settings will not persist. • To avoid this, we can set up a profile for Selenium to use, where these preferences are set as required. Selenium Code to Initialize Profile: ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile profile = allProfiles.getProfile("Selenium"); 8 www.destinationqa.com
  • 9. The Java AWT Robot Class This class can generate native input events to the underlying OS using the Keyboard and Mouse Interfaces Methods in this class can be effectively used to do the minimal interaction with native popups occurring in Web Applications. Some of the useful API provided are: • keyPress(); • mousePress(); • Mousemove(); 9 www.destinationqa.com
  • 10. The Java AWT Robot Class Contd.. Although the Robot Class can be used to interact with PopUps, there are some limitations like: • All interactions happen using either Keyboard events or screen coordinates. • Keyboard events handle 1 character at a time (no Strings) • Cannot capture object properties using this class. www.destinationqa.com 10
  • 11. Using External Programs (AutoIT) AutoIT is a tool that can automate the Windows GUI. AutoIT generates an executable file that can be called from the Selenium script. AutoIT Code Example: WinWaitActive("Choose File to Upload") Send("D:test.jpeg") Send("{ENTER}") Download AutoIT at: http://www.autoitscript.com/site/autoit/downloads/ www.destinationqa.com 11
  • 12. Thank You… Aparna Naik Email: [email protected] Tel: +91 99233 50980 12 www.destinationqa.com