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