DEV Community

Cover image for How to Handle Alerts,Confirmation Box and Popups in Selenium Like a PRO?
Pramod Dutta
Pramod Dutta

Posted on

How to Handle Alerts,Confirmation Box and Popups in Selenium Like a PRO?

✅ Join us - https://sendfox.com/thetestingacademy

In this video, We are going to learn How To Handle Alerts in Selenium and How To Popups Alerts in Selenium, I am going to show step by step How to handle them with accept, dismiss and send Keys methods provided by Selenium.

🚀 Download code : https://codeshare.io/5wXoVK
🚀 Reference Link - https://medium.com/@madhankumaravelu93/selenium-cheat-sheet-a-comprehensive-list-of-selenium-commands-fa4c5c9d11ab

🚀 What is Javascript Alert?
One useful function that's native to JavaScript is the alert() function. This function will display text in a dialog box that pops up on the screen.
With just accept button information

🚀 Handling Confirm Box in Selenium

A confirm box is similar to an alert, except the user can also choose to cancel the message

A confirm box is often used if you want the user to verify or accept something.

When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed.

If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false.

🚀 What is Prompt Box and How to handle it in Selenium?
A prompt box is often used if you want the user to input a value before entering a page.

When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value.

If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null.
Source - https://www.w3schools.com/js/js_popup.asp

Prompt Box
Confirm + they also include a text input.

Alert alert = driver.switchTo().alert();
alert.accept();
alert.dismiss();

🚀 Demo Website Used - https://the-internet.herokuapp.com/javascript_alerts

🚀 What is Automation Testing?
Automation testing is a Software testing technique to test and compare the actual outcome with the expected outcome.

This can be achieved by writing test scripts or using any automation testing tool.

🚀 What is Test automation?
Test automation is used to automate repetitive tasks and other testing tasks which are difficult to perform manually.

🚀Why we do Automation Testing?

  • Eliminate the manual efforts
  • Ad hoc Test- cases are required to run.
  • Rerun the critical or important cases continuously.
  • Long manual flows are tidies

🚀What is 30 Days of Automation in Testing Challenge?

This video is part of 30 Days of Automation in Testing Challenge. Where we will learn about the different concepts related to Automation Testing for Beginners and topics like

✅ Automation testing features
✅ Approaches to automation testing
✅ What is Automation testing
✅ Why automation testing
✅ Automation testing frameworks
✅ Automation testing advantages
✅ Automation testing benefits
✅ Automation Testing Tools
✅ Automaton Testing Books.
✅ Why you need automation testing.
✅ What is UI Testing
✅ Top Automation blogs to read.
✅ Automation tutorials included Selenium, Cypress, Katalon Studio and Test automation frameworks and may more concepts.

✅ API Testing using Postman -
https://www.learnapitesting.com

✅ Cypress Tutorial with LIVE Projects -
https://cypresstutorial.com

✅ REST API testing with Python -
https://masterapitesting.com

#seleniumtutorial #thetestingacademy #seleniumframework #seleniumjava

seleniumforbeginner

Top comments (0)