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();
driver.get("http://www.agoda.com/?ymsg=1&tick=634955861691");
Alert alt=driver.switchTo().alert();
alt.accept();
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.