SELENIUM BASICS:

  • What is Automation Testing - Advantages & Types of Tools
  • What is Selenium IDE, Selenium RC, Selenium WebDriver, Selenium Grid?
  • Selenium IDE, Firebug & Firepath Installation

  • SELENIUM WEBDRIVER:

  • Selenium WebDriver Architecture
  • Selenium Installation
  • Challenges and Limitations of Selenium
  • First Selenium WebDriver Script
  • Working with Firefox Browser
  • Solution - Failed To Launch Browser Using Selenium WebDriver
  • Working with Chrome Browser
  • Working with IE Browser
  • Difference Between FindElement & FindElements
  • Install Firebug, Fire path and other add on for Selenium
  • Locators in Selenium
  • Dynamic Xpath
  • Dynamic CSS
  • Handle drop-downs
  • How to work with file upload
  • Handle Alerts & Popups
  • Handle Multiple Windows
  • Mouse Hover event in Selenium
  • Right Click
  • Double Click
  • Drag and Drop
  • Capture Screenshots in Selenium
  • Parameterization
  • Synchronization
  • Implicit Wait, Explicit Wait and Fluent Wait in Selenium
  • Implicit Waits
  • Explicit WebDriver Waits
  • Fluent Wait In Selenium
  • Apache POI
  • How To Read Data From Excel File
  • How To Write Data In Excel File
  • Database Testing Using MSSQL
  • Database Testing Using MySQL
  • Database Testing Using DB2
  • Handle Ajax Call in Selenium
  • Listeners in Selenium
  • Handling JavaScript in Selenium
  • Stale Element Reference Exception in Selenium
  • Integrate Sikuli with Selenium
  • Headless Browser Testing 
  • Headless Browser Testing using HtmlUnitDriver
  • Headless Browser Testing using PhanthomJSDriver

  • TESTNG:

  • TestNG Installation
  • TestNG Complete Tutorial

  • REPORTS:

  • Extent Reports Introduction
  • Extent Reports Generation
  • Capturing Screenshots & Including In Extent Reports
  • Extent Reports Version 4

  • BUILD & CONTINUOUS INTEGRATION TOOLS:

  • ANT Build Tool - How To Download & Install
  • Maven Build Tool - How To Download & Install
  • Creating Maven Selenium Project
  • GIT Integration with Selenium
  • Jenkins - How To Download & Install
  • Jenkins - Executing TestNG Scripts
  • Jenkins - Generating Reports After Test Execution
  • Jenkins - Executing Maven Project
  • Create build and Execute build for nightly execution
  • Send Email report based on build Status
  • Selenium Continuous Integration with Jenkins [Selenium – Maven – Git – Jenkins] – Step By Step Guide

  • CROSS BROWSER TESTING:

  • Running Selenium Tests On BrowserStack
  • Kobiton - Mobile Testing Platform with Real Devices

  • MOBILE TESTING:

  • Mobile Testing Platform with Real Devices

  • AUTOMATION FRAMEWORKS:

  • What is Framework & Types of Framework
  • Page Object Model Design Pattern
  • Data Driven Framework
  • How to explain Test Automation Framework or Selenium Automation Framework Architecture In Interview

  • API Testing:

  • Learn API Testing
  • Postman Tutorial (API Testing with Postman)

  • INTERVIEW QUESTIONS:

  • Test Automation Framework Interview Questions
  • Selenium Interview Questions
  • TestNG Interview Questions
  • Java Interview Questions
  • Python Interview Questions
  • API Testing Interview Questions

  • SAMPLE RESUME:

  • Automation Tester Resume
  • How To Handle Javascript Alerts/PopUps In Selenium WebDriver

    Handling Javascript Alerts/PopUps:

    In this post, we see how to handle javascript alerts/popus. Alerts are basically popup boxes that take your focus away from the current browser and forces you to read the alert message. You need to do some action such as accept or dismiss the alert box to resume your task on the browser.

    To handle alerts popupswe need to do switch to the alert window and call Selenium WebDriver Alert API methods.

    There are two types of alerts.

    1. Windows Based
    2. Web Based/Browser Based

    Here in this post, I confine to Java Script Alerts (A.K.A. Browser/Web Based Alerts).

    For Windows Based, Please check the below link.

    How To Handle Windows Based Pop-ups Using AutoIT (WILL UPDATE SOON)

    To handle Browser based Alerts (Web based alert popups), we use Alert Interface. The Alert Interface provides some methods to handle the popups.

    While running the WebDriver script, the driver control will be on the browser even after the alert generated which means the driver control will be behind the alert pop up. In order to switch the control to alert pop up, we use the following command :

    Once we switch the control from browser to the alert window. We can use the Alert Interface methods to do required actions such as accepting the alert, dismissing the alert, get the text from the alert window, writing some text on the alert window etc.,

    Let’s see the Alert Interface Methods.

    We need to Import a package org.openqa.selenium.Alert to handle the alerts in Selenium.

    To get a handle to the open alert:

    To Click on OK button:

    To click on Cancel button.

    To get the text which is present on the Alert.

    To enter the text into the alert box

    To Authenticate by passing the credentials

    Sample Program:

    If you are not regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.

    Alerts

    Get our latest blog posts delivered to your inbox

    Subscribe and get popular blog posts about software testing industry.

    Rajkumar

    10 thoughts on “How To Handle Javascript Alerts/PopUps In Selenium WebDriver”

    1. How to handle Yes/No Pop up in selenium

      • Hi Vignesh, have you tried alert.accept and alert.dismiss

    2. Rajkumar nice blog

      • Thanks Dhananjay. Keep visiting.

    3. hi, mr.raj
      i want total tutorial pdf file

    4. how to accept alert after clicking through javascript executor as the above functionality not even executing after that

    5. Hi RajKumar,

      Your study materials are very useful for me, i am testing professional and i am learning selenium so i found your materials and your tutorials explains every topic with simple so it’s interesting to learn with practise. Thanks for providing such a wonderful tutorails.

      Regards,
      Subhash shekhar

      • I am glad that you found it useful Subhash Shekhar.

    6. YOUR VERY VERY THANKS A LOTS FROM MY END TO MAKE THIS WEBSITES I LEARN SO MANY BASIC THINGS. PLEASE KEEP WRITING. MAKE SOME CONTENT SPECIALLY ABOUT FRAME DESIGN ETC

      THanks

      • Thanks Punit. Sure we will try to write. Please share about this blog with your friends too.

    Leave a Comment

    Share via
    Copy link
    Powered by Social Snap