001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.samplu.krad.library.controls;
017
018 import org.junit.Test;
019
020 import org.kuali.rice.testtools.selenium.Failable;
021 import org.kuali.rice.testtools.selenium.ITUtil;
022 import org.kuali.rice.testtools.selenium.SmokeTestBase;
023 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
024
025 /**
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028 public class DemoLibraryControlPasswordSmokeTest extends SmokeTestBase {
029
030 /**
031 * /kr-krad/kradsampleapp?viewId=Demo-PasswordControl-View&methodToCall=start
032 */
033 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-PasswordControl-View&methodToCall=start";
034
035 /**
036 * //div[@id='Demo-PasswordControl-Example1']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2']
037 */
038 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']";
039
040 /**
041 * //div[@id='Demo-PasswordControl-Example2']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2']
042 */
043 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']";
044
045 /**
046 * //div[@id='Demo-PasswordControl-Example3']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2' and @disabled='disabled']
047 */
048 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']";
049
050 /**
051 * //div[@id='Demo-PasswordControl-Example4']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2' and @disabled='disabled']
052 */
053 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']";
054
055 /**
056 * //div[@id='Demo-PasswordControl-Example4']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField2']
057 */
058 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']";
059
060 /**
061 * //div[@id='Demo-PasswordControl-Example5']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField4' and @disabled='disabled']
062 */
063 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']";
064
065 /**
066 * //div[@id='Demo-PasswordControl-Example5']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField4']
067 */
068 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']";
069
070 /**
071 * //div[@id='Demo-PasswordControl-Example6']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField6' and @disabled='disabled']
072 */
073 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]";
074
075 /**
076 * //div[@id='Demo-PasswordControl-Example6']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='password' and @name='inputField6']
077 */
078 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']";
079
080 @Override
081 protected String getBookmarkUrl() {
082 return BOOKMARK_URL;
083 }
084
085 @Override
086 protected void navigate() throws Exception {
087 waitAndClickById("Demo-LibraryLink", "");
088 waitAndClickByLinkText("Controls");
089 waitAndClickByLinkText("Password");
090 }
091
092 protected void testLibraryControlPasswordDefault() throws Exception {
093 waitForElementPresentByXpath(DEFAULT_PWD_FIELD_XPATH);
094 waitAndTypeByXpath(DEFAULT_PWD_FIELD_XPATH,"HiPassword!");
095 }
096
097 protected void testLibraryControlPasswordSize() throws Exception {
098 waitAndClickByLinkText("Size");
099 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 }