-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathWaits.java
More file actions
30 lines (20 loc) · 778 Bytes
/
Copy pathWaits.java
File metadata and controls
30 lines (20 loc) · 778 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
package chapter16;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Waits {
public static void main(String[] args) {
ChromeDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://letcode.in/waits");
driver.findElement(By.id("accept")).click();
// driver.switchTo().alert().accept();
WebDriverWait wait = new WebDriverWait(driver, 20);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
System.out.println(alert.getText());
alert.accept();
}
}