-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScrptPopHandel.java
More file actions
36 lines (29 loc) · 1.04 KB
/
Copy pathJavaScrptPopHandel.java
File metadata and controls
36 lines (29 loc) · 1.04 KB
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
package basicselenium;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class JavaScrptPopHandel {
public static void main(String [] args) throws InterruptedException
{
SeleniumDriverClass sel1=new SeleniumDriverClass();
WebDriver driver=sel1.chromediver();
driver.get("http://www.seleniumframework.com/Practiceform/");
driver.manage().window().maximize();
driver.findElement(By.xpath("//button[@id='alert']")).click();
Alert alt =driver.switchTo().alert();
String msg=alt.getText();
System.out.println(msg);
if (msg.equals("Please share this website with your friends and in your organization."))
{
System.out.println("Passed");
}
Thread.sleep(3);
alt.accept();
Thread.sleep(5);
driver.close();
//Timely alert
driver.get("http://www.seleniumframework.com/Practiceform/");
driver.manage().window().maximize();
driver.findElement(By.xpath("//button[@id='alert']")).click();
}
}