View Javadoc

1   /**
2    * Copyright 2005-2013 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 edu.samplu.krad.library.clientresponsiveness;
17  
18  import org.junit.Test;
19  
20  import org.kuali.rice.testtools.selenium.SmokeTestBase;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoLibraryClientResponsivenessDisableSmokeTest extends SmokeTestBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-Disable-View&methodToCall=start
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Disable-View&methodToCall=start";
31     
32      @Override
33      protected String getBookmarkUrl() {
34          return BOOKMARK_URL;
35      }
36  
37      @Override
38      protected void navigate() throws Exception {
39          waitAndClickById("Demo-LibraryLink", "");
40          waitAndClickByLinkText("Client Responsiveness");
41          waitAndClickByLinkText("Disable");
42      }
43  
44      protected void testClientResponsivenessDisable() throws Exception {
45         //Scenario-1 - enabled
46         waitAndClickByXpath("//input[@type='radio' and @value='enable']");
47         waitAndTypeByName("inputField2","a");
48         waitAndTypeByName("inputField3","b");
49         selectByName("inputField4", "Option 2");
50         selectByName("multiSelectField1","Option 3");
51         waitAndClickByXpath("//input[@type='radio' and @value='1']");
52         waitAndClickByName("checkboxesField1");
53         
54         //Scenario-2 - disabled
55         waitAndClickByXpath("//input[@type='radio' and @value='disable']");
56         if(isEnabledByName("inputField2") && isEnabledByName("inputField3") && isEnabledByName("inputField4") && isEnabledByName("inputField6") &&
57                 isEnabledByName("inputField7") && isEnabledByName("multiSelectField1")) {
58             fail("Field Not Disabled Properly.");
59         }
60      }
61      
62      protected void testClientResponsivenessDisableOnChange() throws Exception {
63          selectByName("exampleShown","On change");
64          
65          //Scenario-1
66          assertElementPresentByXpath("//button[@class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']");
67          waitAndTypeByName("inputField10","a");
68          waitAndTypeByName("inputField11","a");
69          waitAndTypeByName("inputField10", "");
70          assertElementPresentByXpath("//button[@class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']");
71        }
72      
73      protected void testClientResponsivenessDisableOnKeyUp() throws Exception {
74          selectByName("exampleShown","On keyup");
75          waitAndTypeByName("inputField13","disable");
76          assertElementPresentByXpath("//button[contains(text(),'Action Button (keyUp)') and @class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']");
77          waitAndClickByLinkText("Usage");
78          assertElementPresentByXpath("//button[contains(text(),'Action Button (change)') and @class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']");
79       }
80      
81      protected void testClientResponsivenessDisableInCollections() throws Exception {
82          selectByName("exampleShown","In Collections");
83          assertElementPresentByXpath("//input[@class='uif-textControl ignoreValid']");
84          selectByName("newCollectionLines['collection1'].field1","Disable");
85          Thread.sleep(1000);
86          assertElementPresentByXpath("//input[@disabled]");
87       }
88      
89      protected void testClientResponsivenessDisableColl() throws Exception {
90          selectByName("exampleShown","Coll. SpringEL Functions");
91          waitAndClickByXpath("//input[@name='checkboxesField2' and @value='1']");
92          assertElementPresentByXpath("//input[@name='inputField20' and @class='uif-textControl disabled']");
93          waitAndClickByXpath("//input[@name='checkboxesField2' and @value='2']");
94          waitAndClickByXpath("//input[@name='checkboxesField2' and @value='3']");
95          assertElementPresentByXpath("//input[@name='inputField21' and @class='uif-textControl disabled']");
96       }
97      
98      @Test
99      public void testClientResponsivenessDisableBookmark() throws Exception {
100         testClientResponsivenessDisable();
101         testClientResponsivenessDisableOnChange();
102         testClientResponsivenessDisableOnKeyUp();
103         testClientResponsivenessDisableInCollections();
104         testClientResponsivenessDisableColl();
105         passed();
106     }
107 
108     @Test
109     public void testClientResponsivenessDisableNav() throws Exception {
110         testClientResponsivenessDisable();
111         testClientResponsivenessDisableOnChange();
112         testClientResponsivenessDisableOnKeyUp();
113         testClientResponsivenessDisableInCollections();
114         testClientResponsivenessDisableColl();
115         passed();
116     }  
117 }