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 017 package edu.sampleu.krad.compview; 018 019 import com.thoughtworks.selenium.SeleneseTestBase; 020 import org.junit.Test; 021 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 022 023 /** 024 * @author Kuali Rice Team (rice.collab@kuali.org) 025 */ 026 public class ConstraintsAft extends WebDriverLegacyITBase { 027 028 /** 029 * /kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3 030 */ 031 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3"; 032 033 @Override 034 protected String getBookmarkUrl() { 035 return BOOKMARK_URL; 036 } 037 038 @Override 039 protected void navigate() throws Exception { 040 waitAndClickKRAD(); 041 waitAndClickByXpath(KITCHEN_SINK_XPATH); 042 switchToWindow(KUALI_UIF_COMPONENTS_WINDOW_XPATH); 043 waitAndClickByXpath("//ul[@class='nav nav-list']/li[5]/a"); 044 waitAndClickByXpath("//a[@id='UifCompView-Navigation3']"); 045 } 046 047 protected void testConstraints() throws Exception { 048 checkForIncidentReport("testConstraints"); 049 050 // TODO break out into smaller methods, especially if a test flaps. https://jira.kuali.org/browse/KULRICE-9711 051 fireEvent("field10", "focus"); 052 waitAndTypeByName("field10", "2"); 053 fireEvent("field10", "blur"); 054 assertAttributeClassRegexMatches("field10", REGEX_ERROR); 055 056 fireEvent("field10", "focus"); 057 clearTextByName("field10"); 058 waitAndTypeByName("field10", "51"); 059 fireEvent("field10", "blur"); 060 assertAttributeClassRegexMatches("field10", REGEX_ERROR); 061 062 fireEvent("field10", "focus"); 063 clearTextByName("field10"); 064 waitAndTypeByName("field10", "25"); 065 fireEvent("field10", "blur"); 066 assertAttributeClassRegexMatches("field10", REGEX_VALID); 067 068 waitAndTypeByName("field14", "A"); 069 fireEvent("field14", "blur"); 070 071 assertAttributeClassRegexMatches("field14", REGEX_ERROR); 072 clearTextByName("field11"); 073 waitAndTypeByName("field11", "A"); 074 fireEvent("field11", "blur"); 075 assertAttributeClassRegexMatches("field11", REGEX_VALID); 076 assertAttributeClassRegexMatches("field14", REGEX_VALID); 077 078 clearTextByName("field11"); 079 waitAndTypeByName("field11", ""); 080 fireEvent("field11", "blur"); 081 assertAttributeClassRegexMatches("field14", REGEX_ERROR); 082 083 clearTextByName("field12"); 084 waitAndTypeByName("field12", "A"); 085 fireEvent("field12", "blur"); 086 assertAttributeClassRegexMatches("field14", REGEX_ERROR); 087 088 clearTextByName("field13"); 089 waitAndTypeByName("field13", "A"); 090 fireEvent("field13", "blur"); 091 assertAttributeClassRegexMatches("field13", REGEX_VALID); 092 assertAttributeClassRegexMatches("field14", REGEX_VALID); 093 094 clearTextByName("field11"); 095 waitAndTypeByName("field11", "A"); 096 fireEvent("field11", "blur"); 097 assertAttributeClassRegexMatches("field11", REGEX_VALID); 098 assertAttributeClassRegexMatches("field14", REGEX_VALID); 099 100 waitAndTypeByName("field18", "A"); 101 fireEvent("field18", "blur"); 102 assertAttributeClassRegexMatches("field18", REGEX_ERROR); 103 104 waitAndTypeByName("field15", "A"); 105 fireEvent("field15", "blur"); 106 assertAttributeClassRegexMatches("field15", REGEX_VALID); 107 assertAttributeClassRegexMatches("field18", REGEX_VALID); 108 109 clearTextByName("field15"); 110 waitAndTypeByName("field15", ""); 111 fireEvent("field15", "blur"); 112 assertAttributeClassRegexMatches("field18", REGEX_ERROR); 113 114 clearTextByName("field16"); 115 waitAndTypeByName("field16", "A"); 116 fireEvent("field16", "blur"); 117 assertAttributeClassRegexMatches("field18", REGEX_ERROR); 118 119 clearTextByName("field17"); 120 waitAndTypeByName("field17", "A"); 121 fireEvent("field17", "blur"); 122 assertAttributeClassRegexMatches("field17", REGEX_VALID); 123 assertAttributeClassRegexMatches("field18", REGEX_VALID); 124 125 clearTextByName("field15"); 126 waitAndTypeByName("field15", "A"); 127 fireEvent("field15", "blur"); 128 assertAttributeClassRegexMatches("field18", REGEX_ERROR); 129 130 waitAndTypeByName("field23", "A"); 131 fireEvent("field23", "blur"); 132 assertAttributeClassRegexMatches("field23", REGEX_ERROR); 133 134 clearTextByName("field19"); 135 waitAndTypeByName("field19", "A"); 136 fireEvent("field19", "blur"); 137 assertAttributeClassRegexMatches("field23", REGEX_VALID); 138 139 clearTextByName("field19"); 140 waitAndTypeByName("field19", ""); 141 fireEvent("field19", "blur"); 142 waitAndTypeByName("field20", "B"); 143 fireEvent("field20", "blur"); 144 assertAttributeClassRegexMatches("field23", REGEX_VALID); 145 146 clearTextByName("field20"); 147 waitAndTypeByName("field20", ""); 148 fireEvent("field20", "blur"); 149 assertAttributeClassRegexMatches("field23", REGEX_ERROR); 150 151 clearTextByName("field21"); 152 waitAndTypeByName("field21", "C"); 153 fireEvent("field21", "blur"); 154 assertAttributeClassRegexMatches("field23", REGEX_ERROR); 155 156 clearTextByName("field22"); 157 waitAndTypeByName("field22", "D"); 158 fireEvent("field22", "blur"); 159 assertAttributeClassRegexMatches("field23", REGEX_VALID); 160 161 clearTextByName("field19"); 162 waitAndTypeByName("field19", "D"); 163 fireEvent("field19", "blur"); 164 assertAttributeClassRegexMatches("field23", REGEX_VALID); 165 166 clearTextByName("field20"); 167 waitAndTypeByName("field20", "D"); 168 fireEvent("field20", "blur"); 169 assertAttributeClassRegexMatches("field23", REGEX_VALID); 170 171 checkByXpath("//*[@name='field24' and @value='case1']"); 172 clearTextByName("field25"); 173 waitAndTypeByName("field25", ""); 174 fireEvent("field25", "blur"); 175 assertAttributeClassRegexMatches("field25", REGEX_ERROR); 176 177 checkByXpath("//*[@name='field24' and @value='case4']"); 178 fireEvent("field24", "blur"); 179 180 for (int second = 0;; second++) { 181 if (second >= waitSeconds) { 182 SeleneseTestBase.fail("timeout"); 183 } 184 try { 185 if (waitAndGetAttributeByName("field25", "class").matches(REGEX_VALID)) { 186 break; 187 } 188 } catch (Exception e) {} 189 Thread.sleep(1000); 190 } 191 192 assertAttributeClassRegexMatches("field25", REGEX_VALID); 193 194 checkByXpath("//*[@name='field24' and @value='case1']"); 195 fireEvent("field24", "blur"); 196 clearTextByName("field25"); 197 waitAndTypeByName("field25", "$100"); 198 fireEvent("field25", "blur"); 199 200 for (int second = 0;; second++) { 201 if (second >= waitSeconds) { 202 SeleneseTestBase.fail("timeout"); 203 } 204 try { 205 if (waitAndGetAttributeByName("field25", "class").matches(REGEX_VALID)) { 206 break; 207 } 208 } catch (Exception e) {} 209 Thread.sleep(1000); 210 } 211 212 assertAttributeClassRegexMatches("field25", REGEX_VALID); 213 214 checkByXpath("//*[@name='field24' and @value='case2']"); 215 fireEvent("field24", "blur"); 216 217 for (int second = 0;; second++) { 218 if (second >= waitSeconds) { 219 SeleneseTestBase.fail("timeout"); 220 } 221 try { 222 if (waitAndGetAttributeByName("field25", "class").matches(REGEX_ERROR)) { 223 break; 224 } 225 } catch (Exception e) {} 226 Thread.sleep(1000); 227 } 228 229 assertAttributeClassRegexMatches("field25", REGEX_ERROR); 230 231 clearTextByName("field25"); 232 waitAndTypeByName("field25", "A100"); 233 fireEvent("field25", "blur"); 234 assertAttributeClassRegexMatches("field25", REGEX_VALID); 235 236 checkByXpath("//*[@name='field24' and @value='case3']"); 237 fireEvent("field24", "blur"); 238 clearTextByName("field26"); 239 waitAndTypeByName("field26", "6000"); 240 fireEvent("field26", "blur"); 241 242 for (int second = 0;; second++) { 243 if (second >= waitSeconds) { 244 SeleneseTestBase.fail("timeout"); 245 } 246 try { 247 if (waitAndGetAttributeByName("field26", "class").matches(REGEX_ERROR)) { 248 break; 249 } 250 } catch (Exception e) {} 251 Thread.sleep(1000); 252 } 253 254 assertAttributeClassRegexMatches("field26", REGEX_ERROR); 255 256 clearTextByName("field26"); 257 waitAndTypeByName("field26", "501"); 258 fireEvent("field26", "blur"); 259 assertAttributeClassRegexMatches("field26", REGEX_ERROR); 260 261 clearTextByName("field26"); 262 waitAndTypeByName("field26", "499"); 263 fireEvent("field26", "blur"); 264 assertAttributeClassRegexMatches("field26", REGEX_VALID); 265 266 clearTextByName("field26"); 267 waitAndTypeByName("field26", "6000"); 268 fireEvent("field26", "blur"); 269 checkByXpath("//*[@name='field24' and @value='case3']"); 270 fireEvent("field24", "blur"); 271 272 for (int second = 0;; second++) { 273 if (second >= waitSeconds) { 274 SeleneseTestBase.fail("timeout"); 275 } 276 try { 277 if (waitAndGetAttributeByName("field26", "class").matches(REGEX_ERROR)) { 278 break; 279 } 280 } catch (Exception e) {} 281 Thread.sleep(1000); 282 } 283 284 assertAttributeClassRegexMatches("field26", REGEX_ERROR); 285 286 checkByXpath("//*[@name='field24' and @value='case4']"); 287 clearTextByName("field27"); 288 waitAndTypeByName("field27", "A"); 289 fireEvent("field27", "blur"); 290 clearTextByName("field28"); 291 waitAndTypeByName("field28", ""); 292 fireEvent("field28", "blur"); 293 294 for (int second = 0;; second++) { 295 if (second >= waitSeconds) { 296 SeleneseTestBase.fail("timeout"); 297 } 298 try { 299 if (waitAndGetAttributeByName("field28", "class").matches(REGEX_ERROR)) { 300 break; 301 } 302 } catch (Exception e) {} 303 Thread.sleep(1000); 304 } 305 306 assertAttributeClassRegexMatches("field28", REGEX_ERROR); 307 308 checkByXpath("//*[@name='field24' and @value='case3']"); 309 fireEvent("field24", "blur"); 310 311 for (int second = 0;; second++) { 312 if (second >= waitSeconds) { 313 SeleneseTestBase.fail("timeout"); 314 } 315 try { 316 if (waitAndGetAttributeByName("field28", "class").matches(REGEX_VALID)) { 317 break; 318 } 319 } catch (Exception e) {} 320 Thread.sleep(1000); 321 } 322 323 assertAttributeClassRegexMatches("field28", REGEX_VALID); 324 325 clearTextByName("field28"); 326 waitAndTypeByName("field28", "B"); 327 fireEvent("field28", "blur"); 328 checkByXpath("//*[@name='field24' and @value='case4']"); 329 fireEvent("field24", "blur"); 330 331 for (int second = 0;; second++) { 332 if (second >= waitSeconds) { 333 SeleneseTestBase.fail("timeout"); 334 } 335 try { 336 if (waitAndGetAttributeByName("field28", "class").matches(REGEX_VALID)) { 337 break; 338 } 339 } catch (Exception e) {} 340 Thread.sleep(1000); 341 } 342 343 assertAttributeClassRegexMatches("field28", REGEX_VALID); 344 345 clearTextByName("field31"); 346 waitAndTypeByName("field31", "B"); 347 clearTextByName("field32"); 348 waitAndTypeByName("field32", "B"); 349 waitAndTypeByName("field33", ""); 350 fireEvent("field33", "blur"); 351 assertAttributeClassRegexMatches("field33", REGEX_ERROR); 352 353 clearTextByName("field33"); 354 waitAndTypeByName("field33", "B"); 355 fireEvent("field33", "blur"); 356 assertAttributeClassRegexMatches("field33", REGEX_VALID); 357 358 clearTextByName("field32"); 359 waitAndTypeByName("field32", "A"); 360 clearTextByName("field33"); 361 waitAndTypeByName("field33", ""); 362 fireEvent("field33", "blur"); 363 assertAttributeClassRegexMatches("field33", REGEX_VALID); 364 } 365 366 @Test 367 public void testConstraintsBookmark() throws Exception { 368 testConstraints(); 369 passed(); 370 } 371 372 @Test 373 public void testConstraintsNav() throws Exception { 374 testConstraints(); 375 passed(); 376 } 377 }