Tuesday, February 12, 2013

How to close a dialog box using Selenium WebDriver

There might be places, when you click on an object a dialog will pop up asking your conformation. How to close those kind of alert messages?

The below code help you to close any such alert boxes.

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

Note: Only a member of this blog may post a comment.