1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.labs.transactional;
17
18 import org.junit.Test;
19 import org.kuali.rice.testtools.selenium.WebDriverUtils;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.WebDriver;
22 import org.openqa.selenium.WebElement;
23 import org.openqa.selenium.support.ui.ExpectedCondition;
24 import org.openqa.selenium.support.ui.WebDriverWait;
25
26
27
28
29 public class LabsLookupTravelAuthorizationDocumentCloseActionAft extends LabsTransactionalBase {
30 public static final String BOOKMARK_URL = "/kr-krad/labs?methodToCall=start&viewId=DocSearchView";
31
32 @Override
33 protected String getBookmarkUrl() {
34 return BOOKMARK_URL;
35 }
36
37 @Override
38 protected void navigate() throws Exception {
39 waitAndClickByLinkText("Iframe - Doc Search");
40 }
41
42 @Test
43 public void testTravelAuthorizationDocumentCloseActionBookmark() throws Exception {
44 testTravelAuthorizationDocumentLookupAndClose();
45 passed();
46 }
47
48 @Test
49 public void testTravelAuthorizationDocumentCloseActionNav() throws Exception {
50 testTravelAuthorizationDocumentLookupAndClose();
51 passed();
52 }
53
54 public void testTravelAuthorizationDocumentLookupAndClose() throws Exception {
55 final String xpathExpression = "//iframe[1]";
56 driver.switchTo().frame(driver.findElement(By.xpath(xpathExpression)));
57
58
59 jGrowl("Type TravelAuthoriztion in documentTypeName input");
60 getElementByAttributeValue("name", "documentTypeName").sendKeys("TravelAuthorization");
61
62
63 jGrowl("Click the Search button");
64 final String imgXpath = "//input[contains(@src,'/kr/static/images/buttonsmall_search.gif')]";
65 waitAndClick(By.xpath(imgXpath));
66
67
68 jGrowl("Click on the first result returned from the search.");
69 String windowHandle = driver.getWindowHandle();
70 waitAndClick(By.xpath("//*[@id=\"row\"]/tbody/tr/td[1]/a"));
71
72
73 new WebDriverWait(driver, 10).until(new ExpectedCondition<Object>() {
74 @Override
75 public Object apply(WebDriver driver) {
76
77 return driver.getWindowHandles().size() > 1;
78 }
79 });
80
81
82 for (String handle : driver.getWindowHandles()) {
83 if (!handle.equals(windowHandle)) {
84 driver.switchTo().window(handle);
85 break;
86 }
87 }
88
89
90 waitAndClickButtonByText("Close", WebDriverUtils.configuredImplicityWait() * 10);
91
92 jGrowl("Click No Confirmation");
93 waitForElementVisibleBy(By.xpath("//div[@data-parent='ConfirmSaveOnCloseDialog']/button[contains(text(),'No')]"));
94 waitAndClickByXpath("//div[@data-parent='ConfirmSaveOnCloseDialog']/button[contains(text(),'No')]");
95
96 waitForPageToLoad();
97
98 assertTextPresent("Development made easy");
99 }
100
101
102
103 }