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