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.controls;
17  
18  import org.junit.Test;
19  
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoControlPasswordAft extends WebDriverLegacyITBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-PasswordControl-View&methodToCall=start
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-PasswordControlView&methodToCall=start";
31      
32      /**
33       * //section[@id='Demo-PasswordControl-Example1']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2']
34       */
35      private static final String DEFAULT_PWD_FIELD_XPATH = "//section[@id='Demo-PasswordControl-Example1']/div/input[@type='password' and @name='inputField2']";
36      
37      /**
38       * //section[@id='Demo-PasswordControl-Example2']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2']
39       */
40      private static final String SIZE_PWD_FIELD_XPATH = "//section[@id='Demo-PasswordControl-Example2']/div/input[@type='password' and @name='inputField2']";
41      
42      /**
43       * //section[@id='Demo-PasswordControl-Example3']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2' and @disabled='disabled']
44       */
45      private static final String DISABLED_PWD_FIELD_XPATH = "//section[@id='Demo-PasswordControl-Example3']/div/input[@type='password' and @name='inputField2' and @disabled='disabled']";
46  
47      /**
48       * //section[@id='Demo-PasswordControl-Example4']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2' and @disabled='disabled']
49       */
50      private static final String EVAL_DISABLED_ON_KEY_UP_PWD_FIELD_XPATH_BEFORE = "//section[@id='Demo-PasswordControl-Example4']/div/input[@type='password' and @name='inputField2' and @disabled='disabled']";
51      
52      /**
53       * //section[@id='Demo-PasswordControl-Example4']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2']
54       */
55      private static final String EVAL_DISALBED_ON_KEY_UP_PWD_FIELD_XPATH_AFTER = "//section[@id='Demo-PasswordControl-Example4']/div/input[@type='password' and @name='inputField2']";
56      
57      /**
58       * //section[@id='Demo-PasswordControl-Example5']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField4' and @disabled='disabled']
59       */
60      private static final String ENABLE_WHEN_CHANGED_PWD_FIELD_XPATH_BEFORE = "//section[@id='Demo-PasswordControl-Example5']/div/input[@type='password' and @name='inputField4' and @disabled='disabled']";
61      
62      /**
63       * //section[@id='Demo-PasswordControl-Example5']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField4']
64       */
65      private static final String ENABLE_WHEN_CHANGED_PWD_FIELD_XPATH_AFTER = "//section[@id='Demo-PasswordControl-Example5']/div/input[@type='password' and @name='inputField4']";
66      
67      /**
68       * //section[@id='Demo-PasswordControl-Example6']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField6' and @disabled='disabled']
69       */
70      private static final String DISABLE_WHEN_CHANGED_PWD_FIELD_XPATH_AFTER = "//section[@id='Demo-PasswordControl-Example6']/div/input[@type='password' and @name='inputField6' and @disabled]";
71      
72      /**
73       * //section[@id='Demo-PasswordControl-Example6']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField6']
74       */
75      private static final String DISABLE_WHEN_CHANGED_PWD_FIELD_XPATH_BEFORE = "//section[@id='Demo-PasswordControl-Example6']/div/input[@type='password' and @name='inputField6']";
76      
77      @Override
78      protected String getBookmarkUrl() {
79          return BOOKMARK_URL;
80      }
81  
82      @Override
83      protected void navigate() throws Exception {
84          waitAndClickById("Demo-LibraryLink", "");
85          waitAndClickByLinkText("Controls");
86          waitAndClickByLinkText("Password");
87      }
88  
89      protected void testLibraryControlPasswordDefault() throws Exception {
90          waitForElementPresentByXpath(DEFAULT_PWD_FIELD_XPATH);
91          waitAndTypeByXpath(DEFAULT_PWD_FIELD_XPATH,"HiPassword!");
92      }
93      
94      protected void testLibraryControlPasswordSize() throws Exception {
95          waitAndClickByLinkText("Size");
96          waitForElementPresentByXpath(SIZE_PWD_FIELD_XPATH);
97          waitAndTypeByXpath(SIZE_PWD_FIELD_XPATH,"HiPasswordHiPasswordHiPasswordHiPasswordHiPasswordHiPassword!");
98      }
99      
100     protected void testLibraryControlPasswordDisabled() throws Exception {
101         waitAndClickByLinkText("Disabled");
102         waitForElementPresentByXpath(DISABLED_PWD_FIELD_XPATH);
103     }
104 
105     protected void testLibraryControlPasswordEvaluateDisabledOnKeyUp() throws Exception {
106         waitAndClickByLinkText("Evaluate disabled on key up");
107         assertElementPresentByXpath(EVAL_DISABLED_ON_KEY_UP_PWD_FIELD_XPATH_BEFORE);
108         waitAndTypeByName("inputField1","a");
109         assertElementPresentByXpath(EVAL_DISALBED_ON_KEY_UP_PWD_FIELD_XPATH_AFTER);
110     }
111     
112     protected void testLibraryControlPasswordEnableWhenChanged() throws Exception {
113         waitAndClickByLinkText("Enable when changed");
114         assertElementPresentByXpath(ENABLE_WHEN_CHANGED_PWD_FIELD_XPATH_BEFORE);
115         waitAndTypeByName("inputField3","a");
116         waitAndClickLinkContainingText("Library Navigation");
117         assertElementPresentByXpath(ENABLE_WHEN_CHANGED_PWD_FIELD_XPATH_AFTER);
118     }
119     
120     protected void testLibraryControlPasswordDisableWhenChanged() throws Exception {
121         waitAndClickByLinkText("Disable when changed");
122         assertElementPresentByXpath(DISABLE_WHEN_CHANGED_PWD_FIELD_XPATH_BEFORE);
123         waitAndTypeByName("inputField5","a");
124         waitAndClickLinkContainingText("Library Navigation");
125         assertElementPresentByXpath(DISABLE_WHEN_CHANGED_PWD_FIELD_XPATH_AFTER);
126     }
127     
128     @Test
129     public void testControlPasswordBookmark() throws Exception {
130         testLibraryControlPasswordDefault();
131         testLibraryControlPasswordSize();
132         testLibraryControlPasswordDisabled();
133         testLibraryControlPasswordEvaluateDisabledOnKeyUp();
134         testLibraryControlPasswordEnableWhenChanged();
135         testLibraryControlPasswordDisableWhenChanged();
136         passed();
137     }
138 
139     @Test
140     public void testControlPasswordNav() throws Exception {
141         testLibraryControlPasswordDefault();
142         testLibraryControlPasswordSize();
143         testLibraryControlPasswordDisabled();
144         testLibraryControlPasswordEvaluateDisabledOnKeyUp();
145         testLibraryControlPasswordEnableWhenChanged();
146         testLibraryControlPasswordDisableWhenChanged();
147         passed();
148     }  
149 }