//How to handle alerts inselenium webdriver
package com.snapdeal;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class AlertTest {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.kesinenitravels.com/CheckFareDetails.aspx");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("ctl00_cpEndUserMain_ibtnSearch")).click();
// Handling alert OK
Alert alert = driver.switchTo().alert();
System.out.println(alert.getText());
alert.accept();
driver.close();
}
}
/*
Output is
Select Source
*/
package com.snapdeal;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class AlertTest {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.kesinenitravels.com/CheckFareDetails.aspx");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.id("ctl00_cpEndUserMain_ibtnSearch")).click();
// Handling alert OK
Alert alert = driver.switchTo().alert();
System.out.println(alert.getText());
alert.accept();
driver.close();
}
}
/*
Output is
Select Source
*/
No comments:
Post a Comment