How to close the dialog box using Selenium WebDriver

03 April, 2014
On some websites when you click on an object a dialog will pop up asking your conformation. To close this kind of alert messages, we can use the below code.

import org.openqa.selenium.Alert;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class PopupDialog 
 public static void main(String[] args) 
  WebDriver driver=new FirefoxDriver();
  Alert alt=driver.switchTo().alert();

No comments:

Post a Comment