-
Notifications
You must be signed in to change notification settings - Fork 441
Expand file tree
/
Copy pathAlertPopUpHandle.java
More file actions
41 lines (25 loc) · 994 Bytes
/
AlertPopUpHandle.java
File metadata and controls
41 lines (25 loc) · 994 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
30
31
32
33
34
35
36
37
38
39
40
41
package SeleniumSessions;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class AlertPopUpHandle {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "/Users/naveenkhunteta/Downloads/chromedriver");
WebDriver driver = new ChromeDriver(); //launch chrome
driver.get("https://mail.rediff.com/cgi-bin/login.cgi");
driver.findElement(By.name("proceed")).click(); //click on Go btn
Thread.sleep(5000);
Alert alert = driver.switchTo().alert();
System.out.println(alert.getText());
String text = alert.getText();
if(text.equalsIgnoreCase("Please enter a valid user name")){
System.out.println("correct alert messg");
}
else{
System.out.println("in-correct alert messg");
}
alert.accept(); //click on OK btn
//alert.dismiss(); //click on cancel btn
}
}