-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample10_1.java
More file actions
27 lines (21 loc) · 835 Bytes
/
Example10_1.java
File metadata and controls
27 lines (21 loc) · 835 Bytes
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
package com.SeleniumTestingSamples.Examples;
import java.time.Duration;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
//ALERT EXAMPLE 1
public class Example10_1 {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new ChromeDriver();
driver.get("https://testpages.herokuapp.com/styled/alerts/alert-test.html");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10000));
WebElement alertBoxElement = driver.findElement(By.id("alertexamples"));
alertBoxElement.click();
Thread.sleep(5000);
Alert alert = driver.switchTo().alert();
alert.accept();
}
}