How To Handle Alert In Selenium WebDriver

Опубликовано: 14 Октябрь 2024
на канале: Teach Yourself Test Automation
247
2

How To Handle Alert In Selenium WebDriver | http://teachyourselftestautomation.com

Hello and welcome to Day 21 - How To Handle Alert In Selenium WebDriver

When you get onto a web page and suddenly there is a pop up which you can not interact with as in right click to inspect elements on the pop up then you are most likely dealing with a java alert pop up

How every if you can indeed inspect elements on a pop up and can automate using normal locator strategies the you are dealing with HTML pop

Selenium webdriver methods only interacts with HTML code so you have to switch from the HTML web page onto the pop up and interact with the pop up in with the methods below;

To carry out a positive action on a java alert pop up (click on ok button)
you use driver.switchTo().alert().accept();
To carry out a nrgtive action on a java alert pop up (click on cancel button)
you use driver.switchTo().alert().dismis();
To grab text from the java alert pop up you use driver.switchTo().alert().getText()
And to print above into console you use
System.out.println(driver.switchTo().alert().getText());

Please see video for live examples on the above    • How To Handle Alert In Selenium WebDr...  

Don't forget to subscribe if you found this video helpful, support the channel and SUBSCRIBE

Many Thanks

Kevin Owasu Itoe

How To Handle Alert In Selenium WebDriver | http://teachyourselftestautomation.com
--------------------------------------------------------------------------------------------------------
#testautomation #teachyourselftestautomation #selenium #webdriver #java
--------------------------------------------------------------------------------------------------------
Follow me @
Facebook:   / kevin.itoe.50  
Google+: https://plus.google.com/u/0/103559195...
Pinterest: https://www.pinterest.co.uk/owasuik/
My Blog: http://teachyourselftestautomation.com/
My YouTube Channel:    / @teachyourselftestautomatio1271  
--------------------------------------------------------------------------------------------------------
My Videos:
   • Install And Configure Java | Selenium...  
   • Eclipse Installation | eclipse softwa...  
   • Java Project Template | Java Projects...  
   • Download And Configure Selenium | Sel...  
   • Basic Selenium Test Script To Invoke ...  
   • Selenium Tutorial | WebDriver Browser...  
   • Selenium Webdriver Locators | Locator...  
   • Find Elements On Web Page With Link T...  
   • How To Validate Xpath And CSS Using B...  
   • How To Write Customized Xpath In Sele...  
   • CSS Selector | How To Write Custom CS...  
   • Preceding-Sibling Xpath | How To Iden...  
   • How To Handle Static Dropdown Seleniu...  
   • What Is The Difference Between Absolu...  
   • Video  
   • How To Automate Selecting A Checkbox ...  
   • How To Automate Radio Button In Selen...  
   • How To Handle Radio Buttons Dynamical...  
   • How To Handle Alert In Selenium WebDr...  
-------------------------------------------------------------------------------------------------------
What Wikipedia says about selenium: https://en.wikipedia.org/wiki/Seleniu...)
What Wikipedia says about test automation: https://en.wikipedia.org/wiki/Test_au...