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.demo.travel.application;
17  
18  import org.apache.commons.lang.RandomStringUtils;
19  import org.junit.Test;
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.openqa.selenium.By;
22  import org.openqa.selenium.WebElement;
23  
24  /**
25   * Tests basic attributes about a transactional document.
26   *
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  public class DemoTravelAuthorizationAft extends WebDriverLegacyITBase {
30  
31      /**
32       * /kr-krad/approval?methodToCall=docHandler&command=initiate&docTypeName=TravelAuthorization
33       */
34      public static final String BOOKMARK_URL = "/kr-krad/approval?methodToCall=docHandler&command=initiate&docTypeName=TravelAuthorization";
35  
36      @Override
37      protected String getBookmarkUrl() {
38          return BOOKMARK_URL;
39      }
40  
41      @Override
42      protected void navigate() throws Exception {
43          waitAndClickDemoLink();
44          waitAndClickByLinkText("Travel Authorization Document");
45      }
46  
47      /**
48       * Tests that the header text is being pulled directly from the document type label.
49       *
50       * @throws Exception for any test exceptions
51       */
52      protected void testHeaderText() throws Exception {
53          WebElement element = findElement(By.cssSelector("#TravelAuthorization_header"));
54          assertEquals("Header content is incorrect", "Travel Authorization Document", element.getText());
55      }
56  
57      protected void testTravelAuthorization() throws Exception {
58          String randomCode = RandomStringUtils.randomAlphabetic(9).toUpperCase();
59          waitAndTypeByName("document.documentHeader.documentDescription","Description : "+randomCode);
60          waitAndClickByXpath("//button[@id='travelerQuickfinder_quickfinder_act']");
61          gotoIframeByXpath("//iframe[@class='uif-iFrame uif-lookupDialog-iframe']");
62          waitAndClickByXpath("//button[contains(text(),'Search')]");
63          waitAndClickByXpath("//a[contains(text(),'return value')]");
64          waitAndTypeByName("document.cellPhoneNumber","8000884215");
65          waitAndClickByXpath("//div[@data-label='Primary Destination Id']/div/div/button");
66          gotoIframeByXpath("//iframe[@class='uif-iFrame uif-lookupDialog-iframe']");
67          waitAndClickByXpath("//button[contains(text(),'Clear Values')]");
68          waitAndClickByXpath("//button[contains(text(),'Search')]");
69          waitAndClickByXpath("//a[contains(text(),'return value')]");
70          waitAndClickByXpath("//button[contains(text(),'Submit')]");
71          waitAndClickConfirmSubmitOk();
72          waitForTextPresent("Document was successfully submitted.");
73      }
74  
75      @Test
76      public void testHeaderTextBookmark() throws Exception {
77          testHeaderText();
78          testTravelAuthorization();
79          passed();
80      }
81  
82      @Test
83      public void testHeaderTextNav() throws Exception {
84          testHeaderText();
85          passed();
86      }
87  }