View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * This class tests the lookup and close actions for the transactional document
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          // search based on document type
59          jGrowl("Type TravelAuthoriztion in documentTypeName input");
60          getElementByAttributeValue("name", "documentTypeName").sendKeys("TravelAuthorization");
61  
62          // click the search button
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          // click on the first item returned.
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          // wait for the new window to pop up
73          new WebDriverWait(driver, 10).until(new ExpectedCondition<Object>() {
74              @Override
75              public Object apply(WebDriver driver) {
76                  //Wait until we have at least two windows.
77                  return driver.getWindowHandles().size() > 1;
78              }
79          });
80  
81          // switch focus to the new handle
82          for (String handle : driver.getWindowHandles()) {
83              if (!handle.equals(windowHandle)) {
84                  driver.switchTo().window(handle);
85                  break;
86              }
87          }
88  
89          // click the close button
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 }