/ /How to handle alerts in Selenium
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class HandlingAlerts {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
String Url = "ur url";
driver.get(Url);
WebElement alert = driver.findElement(By.xpath("html/body/div[1]/center/table/tbody/tr/td/form[1]/p/input"));
alert.click();
Alert popup = driver.switchTo().alert();
System.out.println(popup.getText());
popup.accept();
Thread.sleep(3000);
driver.close();
}
}
Monday, 7 April 2014
Handling Alerts using selenium webdriver
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment