-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToolsQA.java
More file actions
29 lines (22 loc) · 837 Bytes
/
ToolsQA.java
File metadata and controls
29 lines (22 loc) · 837 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
28
29
//Alert box actions
package automation;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ToolsQA {
public static void main(String[] args) throws Throwable {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "D:\\Quastech\\Software\\geckodriver-v0.30.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://demoqa.com/alerts");
//Click Button to see alert
driver.findElement(By.xpath("//button[@id='alertButton']")).click();
Alert a = driver.switchTo().alert();
Thread.sleep(4000);
a.accept();
Thread.sleep(4000);
driver.close();
//On button click, alert will appear after 5 seconds
}
}