SlideShare a Scribd company logo
1 of 12
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

Session 01 - Introduction to Selenium - Part 2
Session 01 - Introduction to Selenium - Part 2Session 01 - Introduction to Selenium - Part 2
Session 01 - Introduction to Selenium - Part 2SiddharthSelenium
 
1 java fundamental KSHRD
1   java fundamental KSHRD1   java fundamental KSHRD
1 java fundamental KSHRDTola Meng
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - IntroductionSachin-QA
 
Selenoid: browsers in containers
Selenoid: browsers in containersSelenoid: browsers in containers
Selenoid: browsers in containersIvan Krutov
 
Selenium By Pravin Mishra
Selenium By Pravin MishraSelenium By Pravin Mishra
Selenium By Pravin MishraPravin Mishra
 
Scalable Selenium cluster: up and running
Scalable Selenium cluster: up and runningScalable Selenium cluster: up and running
Scalable Selenium cluster: up and runningIvan Krutov
 
Selenium RC
Selenium  RCSelenium  RC
Selenium RCANKUR-BA
 
Using protractor to build automated ui tests
Using protractor to build automated ui testsUsing protractor to build automated ui tests
Using protractor to build automated ui tests🌱 Dale Spoonemore
 
Mobile automation: a three act tragedy
Mobile automation: a three act tragedyMobile automation: a three act tragedy
Mobile automation: a three act tragedyIvan Krutov
 
Enyo Hackathon Presentation
Enyo Hackathon PresentationEnyo Hackathon Presentation
Enyo Hackathon PresentationBen Combee
 
Vagrant development environment
Vagrant   development environmentVagrant   development environment
Vagrant development environmentHiraq Citra M
 
How to Handle Multiple Windows in Selenium Webdriver | Edureka
How to Handle Multiple Windows in Selenium Webdriver | EdurekaHow to Handle Multiple Windows in Selenium Webdriver | Edureka
How to Handle Multiple Windows in Selenium Webdriver | EdurekaEdureka!
 
BeEF: The Browser Exploitation Framework
BeEF: The Browser Exploitation FrameworkBeEF: The Browser Exploitation Framework
BeEF: The Browser Exploitation Frameworkawiasecretary
 
Automation Tools Overview
Automation Tools OverviewAutomation Tools Overview
Automation Tools OverviewSachin-QA
 
Appium Meetup #2 - Mobile Web Automation Introduction
Appium Meetup #2 - Mobile Web Automation IntroductionAppium Meetup #2 - Mobile Web Automation Introduction
Appium Meetup #2 - Mobile Web Automation Introductionsnevesbarros
 

What's hot (20)

VorlonJS
VorlonJSVorlonJS
VorlonJS
 
Selenium introduction
Selenium introductionSelenium introduction
Selenium introduction
 
Session 01 - Introduction to Selenium - Part 2
Session 01 - Introduction to Selenium - Part 2Session 01 - Introduction to Selenium - Part 2
Session 01 - Introduction to Selenium - Part 2
 
Selenium presentation
Selenium presentationSelenium presentation
Selenium presentation
 
1 java fundamental KSHRD
1   java fundamental KSHRD1   java fundamental KSHRD
1 java fundamental KSHRD
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
BeEF
BeEFBeEF
BeEF
 
Selenoid: browsers in containers
Selenoid: browsers in containersSelenoid: browsers in containers
Selenoid: browsers in containers
 
Selenium By Pravin Mishra
Selenium By Pravin MishraSelenium By Pravin Mishra
Selenium By Pravin Mishra
 
Scalable Selenium cluster: up and running
Scalable Selenium cluster: up and runningScalable Selenium cluster: up and running
Scalable Selenium cluster: up and running
 
Selenium RC
Selenium  RCSelenium  RC
Selenium RC
 
Selenium
SeleniumSelenium
Selenium
 
Using protractor to build automated ui tests
Using protractor to build automated ui testsUsing protractor to build automated ui tests
Using protractor to build automated ui tests
 
Mobile automation: a three act tragedy
Mobile automation: a three act tragedyMobile automation: a three act tragedy
Mobile automation: a three act tragedy
 
Enyo Hackathon Presentation
Enyo Hackathon PresentationEnyo Hackathon Presentation
Enyo Hackathon Presentation
 
Vagrant development environment
Vagrant   development environmentVagrant   development environment
Vagrant development environment
 
How to Handle Multiple Windows in Selenium Webdriver | Edureka
How to Handle Multiple Windows in Selenium Webdriver | EdurekaHow to Handle Multiple Windows in Selenium Webdriver | Edureka
How to Handle Multiple Windows in Selenium Webdriver | Edureka
 
BeEF: The Browser Exploitation Framework
BeEF: The Browser Exploitation FrameworkBeEF: The Browser Exploitation Framework
BeEF: The Browser Exploitation Framework
 
Automation Tools Overview
Automation Tools OverviewAutomation Tools Overview
Automation Tools Overview
 
Appium Meetup #2 - Mobile Web Automation Introduction
Appium Meetup #2 - Mobile Web Automation IntroductionAppium Meetup #2 - Mobile Web Automation Introduction
Appium Meetup #2 - Mobile Web Automation Introduction
 

Similar to Selenium Webdriver pop up handling

JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTIONProf Ansari
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTIONProf Ansari
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfAnanthReddy38
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium Rohit Thakur
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxTop 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxAnanthReddy38
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programmingKuntal Bhowmick
 
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانیتست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانیirpycon
 
Web Test Automation Framework - IndicThreads Conference
Web Test Automation Framework  - IndicThreads ConferenceWeb Test Automation Framework  - IndicThreads Conference
Web Test Automation Framework - IndicThreads ConferenceIndicThreads
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presentedVijayan Reddy
 
Selenium for Tester.pdf
Selenium for Tester.pdfSelenium for Tester.pdf
Selenium for Tester.pdfRTechRInfoIT
 
Selenium Tutorial
Selenium TutorialSelenium Tutorial
Selenium Tutorialprad_123
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriverRajathi-QA
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programmingKuntal Bhowmick
 
webOS App by Example: Sorting Thoughts
webOS App by Example: Sorting ThoughtswebOS App by Example: Sorting Thoughts
webOS App by Example: Sorting ThoughtsHendrik Ebel
 
Web application penetration testing lab setup guide
Web application penetration testing lab setup guideWeb application penetration testing lab setup guide
Web application penetration testing lab setup guideSudhanshu Chauhan
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using AppiumMindfire Solutions
 

Similar to Selenium Webdriver pop up handling (20)

JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
JAVA INTRODUCTION
JAVA INTRODUCTIONJAVA INTRODUCTION
JAVA INTRODUCTION
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
 
Selenium
SeleniumSelenium
Selenium
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxTop 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانیتست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
تست وب اپ ها با سلنیوم - علیرضا عظیم زاده میلانی
 
Web Test Automation Framework - IndicThreads Conference
Web Test Automation Framework  - IndicThreads ConferenceWeb Test Automation Framework  - IndicThreads Conference
Web Test Automation Framework - IndicThreads Conference
 
Selenium&scrapy
Selenium&scrapySelenium&scrapy
Selenium&scrapy
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
 
Selenium using C# by Yogesh Kumar
Selenium using C# by  Yogesh KumarSelenium using C# by  Yogesh Kumar
Selenium using C# by Yogesh Kumar
 
Selenium for Tester.pdf
Selenium for Tester.pdfSelenium for Tester.pdf
Selenium for Tester.pdf
 
Selenium Tutorial
Selenium TutorialSelenium Tutorial
Selenium Tutorial
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
webOS App by Example: Sorting Thoughts
webOS App by Example: Sorting ThoughtswebOS App by Example: Sorting Thoughts
webOS App by Example: Sorting Thoughts
 
Web application penetration testing lab setup guide
Web application penetration testing lab setup guideWeb application penetration testing lab setup guide
Web application penetration testing lab setup guide
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using Appium
 

Recently uploaded

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

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: naik.aparna@destinationqa.com Tel: +91 99233 50980 12 www.destinationqa.com