package com.switchto.test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import utility.Helper;
public class AlertDemo {
public static void main(String[] args) throws Exception{
WebDriver driver = Helper.launchBrowser("chrome");
driver.navigate().to("http://anish-selenium.blogspot.in/p/blog-page_8.html");
Thread.sleep(5000);
driver.findElement(By.id("btn")).click();
Alert alert = driver.switchTo().alert();
Thread.sleep(3000);
//alert.dismiss();
String alertText = alert.getText();
System.out.println("Alert contains: " + alertText);
alert.accept();
Thread.sleep(3000);
driver.findElement(By.id("editbox")).sendKeys("abcd");
}
}
No comments:
Post a Comment