Selenium WebDriver - Alerts
package SeleniumPractise;
import static org.junit.Assert.*;
import org.junit.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class AlertsHandle {
@Test
public void alertsHandle() throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://ksrtc.in/");
Thread.sleep(2000);
driver.findElement(By.cssSelector(".button1.redbtn")).click();
Thread.sleep(2000);
Alert alt = driver.switchTo().alert();
String exp_msg = alt.getText();
System.out.println(exp_msg);
alt.accept();
Thread.sleep(2000);
assertEquals(exp_msg, "'From' place is required.");
driver.quit();
}
}
package SeleniumPractise;
import static org.junit.Assert.*;
import org.junit.Test;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class AlertsHandle {
@Test
public void alertsHandle() throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://ksrtc.in/");
Thread.sleep(2000);
driver.findElement(By.cssSelector(".button1.redbtn")).click();
Thread.sleep(2000);
Alert alt = driver.switchTo().alert();
String exp_msg = alt.getText();
System.out.println(exp_msg);
alt.accept();
Thread.sleep(2000);
assertEquals(exp_msg, "'From' place is required.");
driver.quit();
}
}
No comments:
Post a Comment