Handle Alert Popup using Selenium

Steps:


  1. Create webdriver instance for any browser.
  2. Get the address of main page.
  3. Switch the control to alert popup do the functionalities like alert accept or delete.
  4. Then again switch control to main window.

Example :

WebDriver driver - new FirefoxDriver();
String mainPage = driver.getWindowHandle();
Alert alt = driver.switchTo().alert();
alt.accept();
alt.dismiss();
// switch control to main page
driver.switchTo().window(mainPage); 

No comments:

Post a Comment

Copyright © 2017 QALEARNINGGUIDE.COM || ALL RIGHTS RESERVED