forked from CourseRepository/SeleniumWebdriverWithJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestPrompt.java
More file actions
45 lines (34 loc) · 1.09 KB
/
TestPrompt.java
File metadata and controls
45 lines (34 loc) · 1.09 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
37
38
39
40
41
42
43
44
45
package testcase;
import helper.AlertHelper;
import helper.ButtonHelper;
import helper.StartWebDriver;
import helper.WindowHelper;
import org.openqa.selenium.By;
import org.testng.annotations.Test;
/**
* @author - rahul.rathore
* @date - 16-Nov-2014
* @project - Webdriver
* @package - testcase
* @file name - TestPrompt.java
*/
public class TestPrompt extends StartWebDriver {
@Test
public void testCasePrompt() {
WindowHelper.navigateToPage("http://www.w3schools.com/js/js_popup.asp");
ButtonHelper.clickButton("//div[@id='main']/div[8]/a");
if(WindowHelper.isBrowserPopupPresent())
WindowHelper.switchTo(1);
driver.switchTo().frame(driver.findElement(By.id("iframeResult")));
ButtonHelper.clickButton("//button[text()='Try it']");
if(AlertHelper.isAlertPresent())
AlertHelper.clickCancel();
ButtonHelper.clickButton("//button[text()='Try it']");
if(AlertHelper.isAlertPresent()){
System.err.println("String : " + AlertHelper.getText());
AlertHelper.sendKeys("Webdriver");
AlertHelper.clickOk();
}
WindowHelper.switchToParentWithClose();
}
}