-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathTestAlerts.java
54 lines (45 loc) · 2.03 KB
/
TestAlerts.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.SeleniumPractice;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
/**
* @author Yadagiri Reddy
* How to handle alerts in a web page using Selenium WebDriver?
*/
public class TestAlerts {
public static void main(String[] args) throws Exception {
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.hyrtutorials.com/p/alertsdemo.html");
//Alert Box
// System.out.println(driver.findElement(By.id("output")).getText());
// driver.findElement(By.id("alertBox")).click();
// System.out.println(driver.switchTo().alert().getText());
// driver.switchTo().alert().accept();
// System.out.println(driver.findElement(By.id("output")).getText());
//Confirm Box
// System.out.println(driver.findElement(By.id("output")).getText());
// driver.findElement(By.id("confirmBox")).click();
// System.out.println(driver.switchTo().alert().getText());
// driver.switchTo().alert().accept();
// System.out.println(driver.findElement(By.id("output")).getText());
// driver.findElement(By.id("confirmBox")).click();
// System.out.println(driver.switchTo().alert().getText());
// driver.switchTo().alert().dismiss();
// System.out.println(driver.findElement(By.id("output")).getText());
//Prompt Box
// System.out.println(driver.findElement(By.id("output")).getText());
// driver.findElement(By.id("promptBox")).click();
// System.out.println(driver.switchTo().alert().getText());
// driver.switchTo().alert().sendKeys("HYR Tutorials");
// driver.switchTo().alert().accept();
// System.out.println(driver.findElement(By.id("output")).getText());
// driver.findElement(By.id("promptBox")).click();
// System.out.println(driver.switchTo().alert().getText());
// driver.switchTo().alert().dismiss();
// System.out.println(driver.findElement(By.id("output")).getText());
driver.quit();
}
}