Alerts by using Switch method

public class Alert {

@Test
public void alerts()
        {


WebDriver driver=new FirefoxDriver();
String alertMessage="";

driver.get("Any url");
driver.findElement(By.xpath("")).click();

Thread.sleep(3000);
alertMessage =driver.switchTo().alert().getText();
driver.switchTo().alert().accept();

System.out.println(alertMessage);
driver.quit();
}

}



No comments:

Post a Comment