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.uif.library.clientresponsiveness;
17  
18  import org.junit.Test;
19  
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.openqa.selenium.By;
22  import org.openqa.selenium.WebElement;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class LibraryClientResponsivenessDisableAft extends WebDriverLegacyITBase {
28  
29      /**
30       * /kr-krad/kradsampleapp?viewId=Demo-DisableView&methodToCall=start
31       */
32      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-DisableView&methodToCall=start";
33     
34      @Override
35      protected String getBookmarkUrl() {
36          return BOOKMARK_URL;
37      }
38  
39      @Override
40      protected void navigate() throws Exception {
41          waitAndClickLibraryLink();
42          waitAndClickByLinkText("Client Responsiveness");
43          waitAndClickByLinkText("Disable");
44      }
45  
46      protected void testClientResponsivenessDisable() throws Exception {
47         //Scenario-1 - enabled
48         waitAndClickByXpath("//input[@type='radio' and @value='enable']");
49         waitAndTypeByName("inputField2","a1");
50         waitAndTypeByName("inputField3","b");
51         selectByName("inputField4", "Option 2");
52         selectByName("multiSelectField1","Option 3");
53         waitAndClickByXpath("//input[@type='radio' and @value='1']");
54         waitAndClickByName("checkboxesField1");
55         waitForElementPresentByXpath("//a[@class='btn btn-default icon-calendar ui-datepicker-trigger']");
56         
57         //Scenario-2 - disabled
58         waitAndClickByXpath("//input[@type='radio' and @value='disable']");
59         if(isEnabledByName("inputField2") && isEnabledByName("inputField3") && isEnabledByName("inputField4") && isEnabledByName("inputField6") &&
60                 isEnabledByName("inputField7") && isEnabledByName("multiSelectField1")) {
61             fail("Field Not Disabled Properly.");
62         }
63  // @Ignore https://jira.kuali.org/browse/KULRICE-12615
64  //       waitAndClickByXpath("//a[@class='btn btn-default icon-edit-sign']");
65  //       if(!isElementPresentByXpath("//div[@class='fancybox-inner']/div/textarea[@disabled]")){
66  //           jiraAwareFail("Textarea in the popup should be disabled but it is not.");
67  //       }
68  // @Ignore https://jira.kuali.org/browse/KULRICE-12616
69  //       waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
70  //       if(isElementPresentByXpath("//a[@class='btn btn-default icon-calendar ui-datepicker-trigger']")){
71  //            jiraAwareFail("Icon for DatePicker has not changed while it is disabled");
72  //       }
73      }
74      
75      protected void testClientResponsivenessDisableOnChange() throws Exception {
76          selectByName("exampleShown","On change");
77          
78          //Scenario-1
79          assertElementPresentByXpath("//button[@class='btn btn-primary uif-action uif-boxLayoutHorizontalItem disabled']");
80          waitAndTypeByName("inputField10","a");
81          waitAndTypeByName("inputField11","a");
82          waitAndTypeByName("inputField10", "");
83          assertElementPresentByXpath("//button[@class='btn btn-primary uif-action uif-boxLayoutHorizontalItem disabled']");
84        }
85      
86      protected void testClientResponsivenessDisableOnKeyUp() throws Exception {
87          selectByName("exampleShown","On keyup");
88          waitAndTypeByName("inputField13","disable");
89          assertElementPresentByXpath("//button[contains(text(),'Action Button (keyUp)') and @class='btn btn-primary uif-action uif-boxLayoutHorizontalItem disabled']");
90          fireEvent("inputField13", "blur");
91          typeTab();
92          assertElementPresentByXpath("//button[contains(text(),'Action Button (change)') and @class='btn btn-primary uif-action uif-boxLayoutHorizontalItem disabled']");
93       }
94      
95      protected void testClientResponsivenessDisableInCollections() throws Exception {
96          selectByName("exampleShown","In Collections");
97          WebElement element = findElement(By.name("newCollectionLines['collection1'].field3"));
98          assertTrue(element.getAttribute("class").contains("ignoreValid"));
99          selectByName("newCollectionLines['collection1'].field2","Disable");
100         Thread.sleep(1000);
101         assertElementPresentByXpath("//input[@disabled]");
102      }
103     
104     protected void testClientResponsivenessDisableColl() throws Exception {
105         selectByName("exampleShown","Coll. SpringEL Functions");
106         waitAndClickByXpath("//input[@name='checkboxesField2' and @value='1']");
107         WebElement element = findElement(By.name("inputField20"));
108         assertTrue(element.getAttribute("class").contains("disabled"));
109         waitAndClickByXpath("//input[@name='checkboxesField2' and @value='2']");
110         waitAndClickByXpath("//input[@name='checkboxesField2' and @value='3']");
111         element = findElement(By.name("inputField21"));
112         assertTrue(element.getAttribute("class").contains("disabled"));
113      }
114     
115     @Test
116     public void testClientResponsivenessDisableBookmark() throws Exception {
117         testClientResponsivenessDisable();
118         testClientResponsivenessDisableOnChange();
119         testClientResponsivenessDisableOnKeyUp();
120         testClientResponsivenessDisableInCollections();
121         testClientResponsivenessDisableColl();
122         passed();
123     }
124 
125     @Test
126     public void testClientResponsivenessDisableNav() throws Exception {
127         testClientResponsivenessDisable();
128         testClientResponsivenessDisableOnChange();
129         testClientResponsivenessDisableInCollections();
130         testClientResponsivenessDisableColl();
131         testClientResponsivenessDisableOnKeyUp();
132         passed();
133     }  
134 }