001 /**
002 * Copyright 2005-2011 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.travel.krad.test;
017
018 import com.thoughtworks.selenium.DefaultSelenium;
019 import com.thoughtworks.selenium.Selenium;
020 import org.junit.After;
021 import org.junit.Before;
022 import org.junit.Test;
023
024 import static org.junit.Assert.assertEquals;
025 import static org.junit.Assert.assertTrue;
026
027 /**
028 * TODO Administrator don't forget to fill this in.
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032 public class UIFComponentValidationRegexPatternIT {
033 private Selenium selenium;
034
035 @Before
036 public void setUp() throws Exception {
037 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
038 selenium.start();
039 }
040
041 @Test
042 public void testValidCharacterConstraint() throws Exception {
043
044 /*
045 * Timestamp pattern validation message says it allows years from 1900 - 2099
046 * In fact it also allows 2999 as the upper limit. This needs to be sorted out.
047 * Test failing this condition is commented in the below code section for Timestamp Validation. Once resolved can be uncommented
048 *
049 */
050
051 selenium.open(System.getProperty("remote.public.url"));
052 assertEquals("Login", selenium.getTitle());
053 selenium.type("__login_user", "admin");
054 selenium.click("//input[@value='Login']");
055 selenium.waitForPageToLoad("50000");
056 assertEquals("Kuali Portal Index", selenium.getTitle());
057 selenium.click("link=Uif Components (Kitchen Sink)");
058 selenium.waitForPageToLoad("50000");
059 assertEquals("Kuali Portal Index", selenium.getTitle());
060 selenium.selectFrame("iframeportlet");
061 selenium.click("link=Validation - Regex");
062 //selenium.waitForPageToLoad("30000");
063 Thread.sleep(5000);
064
065
066 //---------------------------------------------Fixed Point------------------------------//
067 clearText("//input[@name='field50']");
068 selenium.type("//input[@name='field50']", "127.344");
069 selenium.focus("//input[@name='field51']");
070 Thread.sleep(100);
071 assertTrue(selenium.isTextPresent("Must be a positive fixed point number, with 5 max digits and 2 digits to the right of the decimal point"));
072
073 clearText("//input[@name='field50']");
074 selenium.type("//input[@name='field50']", "1234.4");
075 selenium.focus("//input[@name='field51']");
076 Thread.sleep(100);
077 assertTrue(selenium.isTextPresent("Must be a positive fixed point number, with 5 max digits and 2 digits to the right of the decimal point"));
078
079 clearText("//input[@name='field50']");
080 selenium.type("//input[@name='field50']", "1234.434");
081 selenium.focus("//input[@name='field51']");
082 Thread.sleep(100);
083 assertTrue(selenium.isTextPresent("Must be a positive fixed point number, with 5 max digits and 2 digits to the right of the decimal point"));
084
085 clearText("//input[@name='field50']");
086 selenium.type("//input[@name='field50']", "123.67");
087 selenium.focus("//input[@name='field51']");
088 Thread.sleep(100);
089 assertTrue(! selenium.isTextPresent("Must be a positive fixed point number, with 5 max digits and 2 digits to the right of the decimal point"));
090
091 //---------------------------------------------Floating Point------------------------------//
092 clearText("//input[@name='field51']");
093 selenium.type("//input[@name='field51']", "127.");
094 selenium.focus("//input[@name='field77']");
095 Thread.sleep(100);
096 assertTrue(selenium.isTextPresent("Must be a positive or negative number, with any number of digits to the right of the decimal."));
097
098 clearText("//input[@name='field51']");
099 selenium.type("//input[@name='field51']", "1234.4123");
100 selenium.focus("//input[@name='field77']");
101 Thread.sleep(100);
102 assertTrue(! selenium.isTextPresent("Must be a positive or negative number, with any number of digits to the right of the decimal."));
103
104 clearText("//input[@name='field51']");
105 selenium.type("//input[@name='field51']", "1234()98");
106 selenium.focus("//input[@name='field77']");
107 Thread.sleep(100);
108 assertTrue(selenium.isTextPresent("Must be a positive or negative number, with any number of digits to the right of the decimal."));
109
110 clearText("//input[@name='field51']");
111 selenium.type("//input[@name='field51']", "-123.67");
112 selenium.focus("//input[@name='field77']");
113 Thread.sleep(100);
114 assertTrue(! selenium.isTextPresent("Must be a positive or negative number, with any number of digits to the right of the decimal."));
115
116
117 //---------------------------------------------Integer Pattern constraint------------------------------//
118 clearText("//input[@name='field77']");
119 selenium.type("//input[@name='field77']", "127.");
120 selenium.focus("//input[@name='field52']");
121 Thread.sleep(100);
122 assertTrue(selenium.isTextPresent("Must be a positive or negative whole number"));
123
124 clearText("//input[@name='field77']");
125 selenium.type("//input[@name='field77']", "1234.4123");
126 selenium.focus("//input[@name='field52']");
127 Thread.sleep(100);
128 assertTrue(selenium.isTextPresent("Must be a positive or negative whole number"));
129
130 clearText("//input[@name='field77']");
131 selenium.type("//input[@name='field77']", "123E123");
132 selenium.focus("//input[@name='field52']");
133 Thread.sleep(100);
134 assertTrue(selenium.isTextPresent("Must be a positive or negative whole number"));
135
136 clearText("//input[@name='field77']");
137 selenium.type("//input[@name='field77']", "-123");
138 selenium.focus("//input[@name='field52']");
139 Thread.sleep(100);
140 assertTrue(! selenium.isTextPresent("Must be a positive or negative whole number"));
141
142 //---------------------------------------------Phone Text------------------------------//
143 clearText("//input[@name='field52']");
144 selenium.type("//input[@name='field52']", "1271231234");
145 selenium.focus("//input[@name='field53']");
146 Thread.sleep(100);
147 assertTrue(selenium.isTextPresent("Must be a phone number, in the format of ###-###-####."));
148
149
150 clearText("//input[@name='field52']");
151 selenium.type("//input[@name='field52']", "123-123-123");
152 selenium.focus("//input[@name='field53']");
153 Thread.sleep(100);
154 assertTrue(selenium.isTextPresent("Must be a phone number, in the format of ###-###-####."));
155
156 clearText("//input[@name='field52']");
157 selenium.type("//input[@name='field52']", "12-12-123445");
158 selenium.focus("//input[@name='field53']");
159 Thread.sleep(100);
160 assertTrue(selenium.isTextPresent("Must be a phone number, in the format of ###-###-####."));
161
162 clearText("//input[@name='field52']");
163 selenium.type("//input[@name='field52']", "1234-12-1234");
164 selenium.focus("//input[@name='field53']");
165 Thread.sleep(100);
166 assertTrue(selenium.isTextPresent("Must be a phone number, in the format of ###-###-####."));
167
168 clearText("//input[@name='field52']");
169 selenium.type("//input[@name='field52']", "123.123.1234");
170 selenium.focus("//input[@name='field53']");
171 Thread.sleep(100);
172 assertTrue(selenium.isTextPresent("Must be a phone number, in the format of ###-###-####."));
173
174 clearText("//input[@name='field52']");
175 selenium.type("//input[@name='field52']", "123-123-12345");
176 selenium.focus("//input[@name='field53']");
177 Thread.sleep(100);
178 assertTrue(selenium.isTextPresent("Must be a phone number, in the format of ###-###-####."));
179
180 clearText("//input[@name='field52']");
181 selenium.type("//input[@name='field52']", "123-123-1234");
182 selenium.focus("//input[@name='field53']");
183 Thread.sleep(100);
184 assertTrue(! selenium.isTextPresent("Must be a phone number, in the format of ###-###-####."));
185
186 //---------------------------------------------JavaClass Text------------------------------//
187 clearText("//input[@name='field53']");
188 selenium.type("//input[@name='field53']", "127");
189 selenium.focus("//input[@name='field54']");
190 Thread.sleep(100);
191 assertTrue(selenium.isTextPresent("Must be a valid Java class name."));
192
193 clearText("//input[@name='field53']");
194 selenium.type("//input[@name='field53']", "TestJava!@#Class");
195 selenium.focus("//input[@name='field54']");
196 Thread.sleep(100);
197 assertTrue(selenium.isTextPresent("Must be a valid Java class name."));
198
199 clearText("//input[@name='field53']");
200 selenium.type("//input[@name='field53']", "Test JavaClass");
201 selenium.focus("//input[@name='field54']");
202 Thread.sleep(100);
203 assertTrue(selenium.isTextPresent("Must be a valid Java class name."));
204
205 clearText("//input[@name='field53']");
206 selenium.type("//input[@name='field53']", "Test JavaClass");
207 selenium.focus("//input[@name='field54']");
208 Thread.sleep(100);
209 assertTrue(selenium.isTextPresent("Must be a valid Java class name."));
210
211 clearText("//input[@name='field53']");
212 selenium.type("//input[@name='field53']", "TestJavaClass");
213 selenium.focus("//input[@name='field54']");
214 Thread.sleep(100);
215 assertTrue(! selenium.isTextPresent("Must be a valid Java class name."));
216
217 //---------------------------------------------Email Text------------------------------//
218 clearText("//input[@name='field54']");
219 selenium.type("//input[@name='field54']", "123@123.123");
220 selenium.focus("//input[@name='field84']");
221 Thread.sleep(100);
222 assertTrue(selenium.isTextPresent("Must be a properly formatted email address."));
223
224 clearText("//input[@name='field54']");
225 selenium.type("//input[@name='field54']", "email.com@emailServer");
226 selenium.focus("//input[@name='field84']");
227 Thread.sleep(100);
228 assertTrue(selenium.isTextPresent("Must be a properly formatted email address."));
229
230 clearText("//input[@name='field54']");
231 selenium.type("//input[@name='field54']", "emailemailServer@.com");
232 selenium.focus("//input[@name='field84']");
233 Thread.sleep(100);
234 assertTrue(selenium.isTextPresent("Must be a properly formatted email address."));
235
236 clearText("//input[@name='field54']");
237 selenium.type("//input[@name='field54']", "email@emailServercom");
238 selenium.focus("//input[@name='field84']");
239 Thread.sleep(100);
240 assertTrue(selenium.isTextPresent("Must be a properly formatted email address."));
241
242 clearText("//input[@name='field54']");
243 selenium.type("//input[@name='field54']", "email@emailServer.com");
244 selenium.focus("//input[@name='field84']");
245 Thread.sleep(100);
246 assertTrue(! selenium.isTextPresent("Must be a properly formatted email address."));
247
248
249 //---------------------------------------------URL pattern Text------------------------------//
250 clearText("//input[@name='field84']");
251 selenium.type("//input[@name='field84']", "www.google.com");
252 selenium.focus("//input[@name='field55']");
253 Thread.sleep(100);
254 assertTrue(selenium.isTextPresent("Must be a valid url beginning with http, https, or ftp"));
255
256 clearText("//input[@name='field84']");
257 selenium.type("//input[@name='field84']", "https:www.google.com");
258 selenium.focus("//input[@name='field55']");
259 Thread.sleep(100);
260 assertTrue(selenium.isTextPresent("Must be a valid url beginning with http, https, or ftp"));
261
262 clearText("//input[@name='field84']");
263 selenium.type("//input[@name='field84']", "ftp://www.google.comsdfa123!#@");
264 selenium.focus("//input[@name='field55']");
265 Thread.sleep(100);
266 assertTrue(selenium.isTextPresent("Must be a valid url beginning with http, https, or ftp"));
267
268 clearText("//input[@name='field84']");
269 selenium.type("//input[@name='field84']", "ftp:/www.google.coms");
270 selenium.focus("//input[@name='field55']");
271 Thread.sleep(100);
272 assertTrue(selenium.isTextPresent("Must be a valid url beginning with http, https, or ftp"));
273
274 clearText("//input[@name='field84']");
275 selenium.type("//input[@name='field84']", "ftp://www.google.com");
276 selenium.focus("//input[@name='field55']");
277 Thread.sleep(100);
278 assertTrue(! selenium.isTextPresent("Must be a valid url beginning with http, https, or ftp"));
279
280 clearText("//input[@name='field84']");
281 selenium.type("//input[@name='field84']", "https://www.google.com");
282 selenium.focus("//input[@name='field55']");
283 Thread.sleep(100);
284 assertTrue(! selenium.isTextPresent("Must be a valid url beginning with http, https, or ftp"));
285
286 clearText("//input[@name='field84']");
287 selenium.type("//input[@name='field84']", "http://www.google.com");
288 selenium.focus("//input[@name='field55']");
289 Thread.sleep(100);
290 assertTrue(! selenium.isTextPresent("Must be a valid url beginning with http, https, or ftp"));
291
292
293 //---------------------------------------------Date pattern Text------------------------------//
294 //-------------invalid formats
295 clearText("//input[@name='field55']");
296 selenium.type("//input[@name='field55']", "12/12/2112 12:12:87 am");
297 selenium.focus("//input[@name='field75']");
298 Thread.sleep(100);
299 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
300
301 clearText("//input[@name='field55']");
302 selenium.type("//input[@name='field55']", "12-12-2112 12:12 am");
303 selenium.focus("//input[@name='field75']");
304 Thread.sleep(100);
305 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
306
307 clearText("//input[@name='field55']");
308 selenium.type("//input[@name='field55']", "12-12-2112 12:12");
309 selenium.focus("//input[@name='field75']");
310 Thread.sleep(100);
311 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
312
313 clearText("//input[@name='field55']");
314 selenium.type("//input[@name='field55']", "12/12/2112 12:12");
315 selenium.focus("//input[@name='field75']");
316 Thread.sleep(100);
317 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
318
319 clearText("//input[@name='field55']");
320 selenium.type("//input[@name='field55']", "12-12-2112 12:12:78");
321 selenium.focus("//input[@name='field75']");
322 Thread.sleep(100);
323 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
324
325 clearText("//input[@name='field55']");
326 selenium.type("//input[@name='field55']", "12 Sept");
327 selenium.focus("//input[@name='field75']");
328 Thread.sleep(100);
329 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
330
331 clearText("//input[@name='field55']");
332 selenium.type("//input[@name='field55']", "Sept 12 12:12");
333 selenium.focus("//input[@name='field75']");
334 Thread.sleep(100);
335 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
336
337 clearText("//input[@name='field55']");
338 selenium.type("//input[@name='field55']", "221299 12:12:13");
339 selenium.focus("//input[@name='field75']");
340 Thread.sleep(100);
341 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
342
343 clearText("//input[@name='field55']");
344 selenium.type("//input[@name='field55']", "111222 12:12");
345 selenium.focus("//input[@name='field75']");
346 Thread.sleep(100);
347 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
348
349 clearText("//input[@name='field55']");
350 selenium.type("//input[@name='field55']", "9/9/2012 12:12 am");
351 selenium.focus("//input[@name='field75']");
352 Thread.sleep(100);
353 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
354
355 //-------------valid formats
356 clearText("//input[@name='field55']");
357 selenium.type("//input[@name='field55']", "09/09/2012 12:12 pm");
358 selenium.focus("//input[@name='field75']");
359 Thread.sleep(100);
360 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
361
362 clearText("//input[@name='field55']");
363 selenium.type("//input[@name='field55']", "090923");
364 selenium.focus("//input[@name='field75']");
365 Thread.sleep(100);
366 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
367
368 clearText("//input[@name='field55']");
369 selenium.type("//input[@name='field55']", "Sept 12");
370 selenium.focus("//input[@name='field75']");
371 Thread.sleep(100);
372 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
373
374
375 clearText("//input[@name='field55']");
376 selenium.type("//input[@name='field55']", "2034");
377 selenium.focus("//input[@name='field75']");
378 Thread.sleep(100);
379 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
380
381 clearText("//input[@name='field55']");
382 selenium.type("//input[@name='field55']", "12/12/2012 23:12:59");
383 selenium.focus("//input[@name='field75']");
384 Thread.sleep(100);
385 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
386
387 clearText("//input[@name='field55']");
388 selenium.type("//input[@name='field55']", "12-12-12 23:12:59");
389 selenium.focus("//input[@name='field75']");
390 Thread.sleep(100);
391 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
392
393 clearText("//input[@name='field55']");
394 selenium.type("//input[@name='field55']", "121212 23:12:32");
395 selenium.focus("//input[@name='field75']");
396 Thread.sleep(100);
397 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
398
399 clearText("//input[@name='field55']");
400 selenium.type("//input[@name='field55']", "Sept 12 23:45:50");
401 selenium.focus("//input[@name='field75']");
402 Thread.sleep(100);
403 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
404
405 clearText("//input[@name='field55']");
406 selenium.type("//input[@name='field55']", "2011 12:23:32");
407 selenium.focus("//input[@name='field75']");
408 Thread.sleep(100);
409 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yyyy hh:mm a, MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy, MMddyy, MMMM dd, yyyy, MM/dd/yy HH:mm:ss, MM/dd/yyyy HH:mm:ss, MM-dd-yy HH:mm:ss, MMddyy HH:mm:ss, MMMM dd HH:mm:ss, yyyy HH:mm:ss"));
410
411
412 //---------------------------------------------BasicDate pattern Text------------------------------//
413 clearText("//input[@name='field75']");
414 selenium.type("//input[@name='field75']", "12122012");
415 selenium.focus("//input[@name='field82']");
416 Thread.sleep(100);
417 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy"));
418
419 clearText("//input[@name='field75']");
420 selenium.type("//input[@name='field75']", "13-12-34");
421 selenium.focus("//input[@name='field82']");
422 Thread.sleep(100);
423 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy"));
424
425 clearText("//input[@name='field75']");
426 selenium.type("//input[@name='field75']", "12:12:2034");
427 selenium.focus("//input[@name='field82']");
428 Thread.sleep(100);
429 assertTrue(selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy"));
430
431 clearText("//input[@name='field75']");
432 selenium.type("//input[@name='field75']", "12-12-2034");
433 selenium.focus("//input[@name='field82']");
434 Thread.sleep(100);
435 assertTrue(! selenium.isTextPresent("Must be a date in the following format(s): MM/dd/yy, MM/dd/yyyy, MM-dd-yy, MM-dd-yyyy"));
436
437
438 //---------------------------------------------Time12H Pattern Text------------------------------//
439 clearText("//input[@name='field82']");
440 selenium.type("//input[@name='field82']", "13:00:12");
441 selenium.focus("//input[@name='field83']");
442 Thread.sleep(100);
443 assertTrue(selenium.isTextPresent("Must be a valid 12 hour time in HH:mm format, seconds are optional"));
444
445 clearText("//input[@name='field82']");
446 selenium.type("//input[@name='field82']", "09:00:");
447 selenium.focus("//input[@name='field83']");
448 Thread.sleep(100);
449 assertTrue(selenium.isTextPresent("Must be a valid 12 hour time in HH:mm format, seconds are optional"));
450
451 clearText("//input[@name='field82']");
452 selenium.type("//input[@name='field82']", "3-00:12");
453 selenium.focus("//input[@name='field83']");
454 Thread.sleep(100);
455 assertTrue(selenium.isTextPresent("Must be a valid 12 hour time in HH:mm format, seconds are optional"));
456
457 clearText("//input[@name='field82']");
458 selenium.type("//input[@name='field82']", "3:00:34");
459 selenium.focus("//input[@name='field83']");
460 Thread.sleep(100);
461 assertTrue(! selenium.isTextPresent("Must be a valid 12 hour time in HH:mm format, seconds are optional"));
462
463 clearText("//input[@name='field82']");
464 selenium.type("//input[@name='field82']", "3:00");
465 selenium.focus("//input[@name='field83']");
466 Thread.sleep(100);
467 assertTrue(! selenium.isTextPresent("Must be a valid 12 hour time in HH:mm format, seconds are optional"));
468
469
470 //---------------------------------------------Time24H Pattern Text------------------------------//
471 clearText("//input[@name='field83']");
472 selenium.type("//input[@name='field83']", "24:00:12");
473 selenium.focus("//input[@name='field56']");
474 Thread.sleep(100);
475 assertTrue(selenium.isTextPresent("Must be a valid 24 hour (0-23) time in HH:mm format, seconds are optional"));
476
477 clearText("//input[@name='field83']");
478 selenium.type("//input[@name='field83']", "14:00:");
479 selenium.focus("//input[@name='field56']");
480 Thread.sleep(100);
481 assertTrue(selenium.isTextPresent("Must be a valid 24 hour (0-23) time in HH:mm format, seconds are optional"));
482
483 clearText("//input[@name='field83']");
484 selenium.type("//input[@name='field83']", "13:00:76");
485 selenium.focus("//input[@name='field56']");
486 Thread.sleep(100);
487 assertTrue(selenium.isTextPresent("Must be a valid 24 hour (0-23) time in HH:mm format, seconds are optional"));
488
489 clearText("//input[@name='field83']");
490 selenium.type("//input[@name='field83']", "13:00:23");
491 selenium.focus("//input[@name='field56']");
492 Thread.sleep(100);
493 assertTrue(! selenium.isTextPresent("Must be a valid 24 hour (0-23) time in HH:mm format, seconds are optional"));
494
495 clearText("//input[@name='field83']");
496 selenium.type("//input[@name='field83']", "23:00:12");
497 selenium.focus("//input[@name='field56']");
498 Thread.sleep(100);
499 assertTrue(! selenium.isTextPresent("Must be a valid 24 hour (0-23) time in HH:mm format, seconds are optional"));
500
501
502
503
504 //---------------------------------------------Timestamp pattern Text------------------------------//
505 clearText("//input[@name='field56']");
506 selenium.type("//input[@name='field56']", "1000-12-12 12:12:12.103");
507 selenium.focus("//input[@name='field57']");
508 Thread.sleep(100);
509 assertTrue(selenium.isTextPresent("Must be a date/time in the format of yyyy-mm-dd hh:mm:ss.ms, between the years of 1900 and 2099, inclusive. \"ms\" represents milliseconds, and must be included."));
510
511 clearText("//input[@name='field56']");
512 selenium.type("//input[@name='field56']", "2000/12/12 12-12-12.87");
513 selenium.focus("//input[@name='field57']");
514 Thread.sleep(100);
515 assertTrue(selenium.isTextPresent("Must be a date/time in the format of yyyy-mm-dd hh:mm:ss.ms, between the years of 1900 and 2099, inclusive. \"ms\" represents milliseconds, and must be included."));
516
517 clearText("//input[@name='field56']");
518 selenium.type("//input[@name='field56']", "2000/12/12 12-12-12.87");
519 selenium.focus("//input[@name='field57']");
520 Thread.sleep(100);
521 assertTrue(selenium.isTextPresent("Must be a date/time in the format of yyyy-mm-dd hh:mm:ss.ms, between the years of 1900 and 2099, inclusive. \"ms\" represents milliseconds, and must be included."));
522
523 clearText("//input[@name='field56']");
524 selenium.type("//input[@name='field56']", "2011-08-12 12:12:12");
525 selenium.focus("//input[@name='field57']");
526 Thread.sleep(100);
527 assertTrue(selenium.isTextPresent("Must be a date/time in the format of yyyy-mm-dd hh:mm:ss.ms, between the years of 1900 and 2099, inclusive. \"ms\" represents milliseconds, and must be included."));
528
529 //--------this should not be allowed
530 /*
531 clearTimeStampText();
532 selenium.type("//input[@name='field56']", "2999-12-12 12:12:12.103");
533 selenium.focus("//input[@name='field57']");
534 Thread.sleep(100);
535 assertTrue(selenium.isTextPresent("Must be a date/time in the format of yyyy-mm-dd hh:mm:ss.ms, between the years of 1900 and 2099, inclusive. \"ms\" represents milliseconds, and must be included."));
536
537 */
538 clearText("//input[@name='field56']");
539 selenium.type("//input[@name='field56']", "2099-12-12 12:12:12.103");
540 selenium.focus("//input[@name='field57']");
541 Thread.sleep(100);
542 assertTrue(! selenium.isTextPresent("Must be a date/time in the format of yyyy-mm-dd hh:mm:ss.ms, between the years of 1900 and 2099, inclusive. \"ms\" represents milliseconds, and must be included."));
543
544
545 //---------------------------------------------Year Pattern Text------------------------------//
546 clearText("//input[@name='field57']");
547 selenium.type("//input[@name='field57']", "1599");
548 selenium.focus("//input[@name='field58']");
549 Thread.sleep(100);
550 assertTrue(selenium.isTextPresent("Must be a four digit year between 1600 to 2199, inclusive."));
551
552 clearText("//input[@name='field57']");
553 selenium.type("//input[@name='field57']", "2200");
554 selenium.focus("//input[@name='field58']");
555 Thread.sleep(100);
556 assertTrue(selenium.isTextPresent("Must be a four digit year between 1600 to 2199, inclusive."));
557
558 clearText("//input[@name='field57']");
559 selenium.type("//input[@name='field57']", "20000");
560 selenium.focus("//input[@name='field58']");
561 Thread.sleep(100);
562 assertTrue(selenium.isTextPresent("Must be a four digit year between 1600 to 2199, inclusive."));
563
564 clearText("//input[@name='field57']");
565 selenium.type("//input[@name='field57']", "-202");
566 selenium.focus("//input[@name='field58']");
567 Thread.sleep(100);
568 assertTrue(selenium.isTextPresent("Must be a four digit year between 1600 to 2199, inclusive."));
569
570 clearText("//input[@name='field57']");
571 selenium.type("//input[@name='field57']", "2000");
572 selenium.focus("//input[@name='field58']");
573 Thread.sleep(100);
574 assertTrue(! selenium.isTextPresent("Must be a four digit year between 1600 to 2199, inclusive."));
575
576 //---------------------------------------------Month Pattern Text------------------------------//
577 clearText("//input[@name='field58']");
578 selenium.type("//input[@name='field58']", "0");
579 selenium.focus("//input[@name='field61']");
580 Thread.sleep(100);
581 assertTrue(selenium.isTextPresent("Must be 1 to 12, representing a month."));
582
583 clearText("//input[@name='field58']");
584 selenium.type("//input[@name='field58']", "-12");
585 selenium.focus("//input[@name='field61']");
586 Thread.sleep(100);
587 assertTrue(selenium.isTextPresent("Must be 1 to 12, representing a month."));
588
589 clearText("//input[@name='field58']");
590 selenium.type("//input[@name='field58']", "100");
591 selenium.focus("//input[@name='field61']");
592 Thread.sleep(100);
593 assertTrue(selenium.isTextPresent("Must be 1 to 12, representing a month."));
594
595 clearText("//input[@name='field58']");
596 selenium.type("//input[@name='field58']", "12");
597 selenium.focus("//input[@name='field61']");
598 Thread.sleep(100);
599 assertTrue(! selenium.isTextPresent("Must be 1 to 12, representing a month."));
600
601
602 //---------------------------------------------ZipCode Pattern Text------------------------------//
603
604 clearText("//input[@name='field61']");
605 selenium.type("//input[@name='field61']", "123");
606 selenium.focus("//input[@name='field62']");
607 Thread.sleep(100);
608 assertTrue(selenium.isTextPresent("Must be a ZIP code. ZIP + 4 codes are also accepted."));
609
610 clearText("//input[@name='field61']");
611 selenium.type("//input[@name='field61']", "2341 12");
612 selenium.focus("//input[@name='field62']");
613 Thread.sleep(100);
614 assertTrue(selenium.isTextPresent("Must be a ZIP code. ZIP + 4 codes are also accepted."));
615
616 clearText("//input[@name='field61']");
617 selenium.type("//input[@name='field61']", "0-1231");
618 selenium.focus("//input[@name='field62']");
619 Thread.sleep(100);
620 assertTrue(selenium.isTextPresent("Must be a ZIP code. ZIP + 4 codes are also accepted."));
621
622 clearText("//input[@name='field61']");
623 selenium.type("//input[@name='field61']", "12345");
624 selenium.focus("//input[@name='field62']");
625 Thread.sleep(100);
626 assertTrue(! selenium.isTextPresent("Must be a ZIP code. ZIP + 4 codes are also accepted."));
627
628
629 //---------------------------------------------Alpha Numeric w/o options Text------------------------------//
630 clearText("//input[@name='field62']");
631 selenium.type("//input[@name='field62']", "123 23 @#");
632 selenium.focus("//input[@name='field63']");
633 Thread.sleep(100);
634 assertTrue(selenium.isTextPresent("Can only be alphanumeric characters "));
635
636 clearText("//input[@name='field62']");
637 selenium.type("//input[@name='field62']", "-asd123");
638 selenium.focus("//input[@name='field63']");
639 Thread.sleep(100);
640 assertTrue(selenium.isTextPresent("Can only be alphanumeric characters "));
641
642 clearText("//input[@name='field62']");
643 selenium.type("//input[@name='field62']", "asd/123");
644 selenium.focus("//input[@name='field63']");
645 Thread.sleep(100);
646 assertTrue(selenium.isTextPresent("Can only be alphanumeric characters "));
647
648 clearText("//input[@name='field62']");
649 selenium.type("//input[@name='field62']", "asd123");
650 selenium.focus("//input[@name='field63']");
651 Thread.sleep(100);
652 assertTrue(! selenium.isTextPresent("Can only be alphanumeric characters "));
653
654 //---------------------------------------------Alpha Numeric with options Text------------------------------//
655 clearText("//input[@name='field63']");
656 selenium.type("//input[@name='field63']", "123^we");
657 selenium.focus("//input[@name='field64']");
658 Thread.sleep(100);
659 assertTrue(selenium.isTextPresent("Can only be alphanumeric characters, whitespace, underscores, forward slashes "));
660
661 clearText("//input[@name='field63']");
662 selenium.type("//input[@name='field63']", "-123_asd");
663 selenium.focus("//input[@name='field64']");
664 Thread.sleep(100);
665 assertTrue(selenium.isTextPresent("Can only be alphanumeric characters, whitespace, underscores, forward slashes "));
666
667 clearText("//input[@name='field63']");
668 selenium.type("//input[@name='field63']", "123 23 @#");
669 selenium.focus("//input[@name='field64']");
670 Thread.sleep(100);
671 assertTrue(selenium.isTextPresent("Can only be alphanumeric characters, whitespace, underscores, forward slashes "));
672
673 clearText("//input[@name='field63']");
674 selenium.type("//input[@name='field63']", "as_de 456/123");
675 selenium.focus("//input[@name='field64']");
676 Thread.sleep(100);
677 assertTrue(! selenium.isTextPresent("Can only be alphanumeric characters, whitespace, underscores, forward slashes "));
678
679 //---------------------------------------------Alpha with Whitespace and commas Text------------------------------//
680 clearText("//input[@name='field64']");
681 selenium.type("//input[@name='field64']", "123^we");
682 selenium.focus("//input[@name='field76']");
683 Thread.sleep(100);
684 assertTrue(selenium.isTextPresent("Can only be alpha characters, whitespace, commas"));
685
686 clearText("//input[@name='field64']");
687 selenium.type("//input[@name='field64']", "asd_pqr");
688 selenium.focus("//input[@name='field76']");
689 Thread.sleep(100);
690 assertTrue(selenium.isTextPresent("Can only be alpha characters, whitespace, commas"));
691
692 clearText("//input[@name='field64']");
693 selenium.type("//input[@name='field64']", "asd/def");
694 selenium.focus("//input[@name='field76']");
695 Thread.sleep(100);
696 assertTrue(selenium.isTextPresent("Can only be alpha characters, whitespace, commas"));
697
698 clearText("//input[@name='field64']");
699 selenium.type("//input[@name='field64']", "asd ,pqr");
700 selenium.focus("//input[@name='field76']");
701 Thread.sleep(100);
702 assertTrue(! selenium.isTextPresent("Can only be alpha characters, whitespace, commas"));
703
704
705 //---------------------------------------------AlphaPatterrn with disallowed charset Text------------------------------//
706 clearText("//input[@name='field76']");
707 selenium.type("//input[@name='field76']", "123");
708 selenium.focus("//input[@name='field65']");
709 Thread.sleep(100);
710 assertTrue(selenium.isTextPresent("Can only be alpha characters, whitespace, underscores, periods, parentheses, dollar signs, forward slashes, double quotes, apostrophes, commas, colons, null, question marks, exclaimation marks, dashes, plus signs, equals signs, *, @, %, #"));
711
712 clearText("//input[@name='field76']");
713 selenium.type("//input[@name='field76']", "<abcd>");
714 selenium.focus("//input[@name='field65']");
715 Thread.sleep(100);
716 assertTrue(selenium.isTextPresent("Can only be alpha characters, whitespace, underscores, periods, parentheses, dollar signs, forward slashes, double quotes, apostrophes, commas, colons, null, question marks, exclaimation marks, dashes, plus signs, equals signs, *, @, %, #"));
717
718 clearText("//input[@name='field76']");
719 selenium.type("//input[@name='field76']", "|abcd|");
720 selenium.focus("//input[@name='field65']");
721 Thread.sleep(100);
722 assertTrue(selenium.isTextPresent("Can only be alpha characters, whitespace, underscores, periods, parentheses, dollar signs, forward slashes, double quotes, apostrophes, commas, colons, null, question marks, exclaimation marks, dashes, plus signs, equals signs, *, @, %, #"));
723
724 clearText("//input[@name='field76']");
725 selenium.type("//input[@name='field76']", "~abcd~");
726 selenium.focus("//input[@name='field65']");
727 Thread.sleep(100);
728 assertTrue(selenium.isTextPresent("Can only be alpha characters, whitespace, underscores, periods, parentheses, dollar signs, forward slashes, double quotes, apostrophes, commas, colons, null, question marks, exclaimation marks, dashes, plus signs, equals signs, *, @, %, #"));
729
730 clearText("//input[@name='field76']");
731 selenium.type("//input[@name='field76']", " ab_c d_ef ");
732 selenium.focus("//input[@name='field65']");
733 Thread.sleep(100);
734 assertTrue(! selenium.isTextPresent("Can only be alpha characters, whitespace, underscores, periods, parentheses, dollar signs, forward slashes, double quotes, apostrophes, commas, colons, null, question marks, exclaimation marks, dashes, plus signs, equals signs, *, @, %, #"));
735
736
737 //---------------------------------------------Anything with No Whitespace Text------------------------------//
738 clearText("//input[@name='field65']");
739 selenium.type("//input[@name='field65']", "123 ^we");
740 selenium.focus("//input[@name='field66']");
741 Thread.sleep(100);
742 assertTrue(selenium.isTextPresent("Must not contain any whitespace (spaces, returns, etc)"));
743
744 clearText("//input[@name='field65']");
745 selenium.type("//input[@name='field65']", "123^we!@#^&*~:");
746 selenium.focus("//input[@name='field66']");
747 Thread.sleep(100);
748 assertTrue(! selenium.isTextPresent("Must not contain any whitespace (spaces, returns, etc)"));
749
750 //---------------------------------------------CharacterSet Text------------------------------//
751 clearText("//input[@name='field66']");
752 selenium.type("//input[@name='field66']", "123 ^we");
753 selenium.focus("//input[@name='field67']");
754 Thread.sleep(100);
755 assertTrue(selenium.isTextPresent("Can be any of the following characters: abcABC"));
756
757 clearText("//input[@name='field66']");
758 selenium.type("//input[@name='field66']", "123_^we");
759 selenium.focus("//input[@name='field67']");
760 Thread.sleep(100);
761 assertTrue(selenium.isTextPresent("Can be any of the following characters: abcABC"));
762
763 clearText("//input[@name='field66']");
764 selenium.type("//input[@name='field66']", "abc ABC");
765 selenium.focus("//input[@name='field67']");
766 Thread.sleep(100);
767 assertTrue(selenium.isTextPresent("Can be any of the following characters: abcABC"));
768
769 clearText("//input[@name='field66']");
770 selenium.type("//input[@name='field66']", "aAbBcC");
771 selenium.focus("//input[@name='field67']");
772 Thread.sleep(100);
773 assertTrue(! selenium.isTextPresent("Can be any of the following characters: abcABC"));
774
775 //---------------------------------------------Numeric Character Text------------------------------//
776 clearText("//input[@name='field67']");
777 selenium.type("//input[@name='field67']", "123 ^we");
778 selenium.focus("//input[@name='field68']");
779 Thread.sleep(100);
780 assertTrue(selenium.isTextPresent("Can only be numeric characters, parentheses, dashes"));
781
782 clearText("//input[@name='field67']");
783 selenium.type("//input[@name='field67']", "123/10");
784 selenium.focus("//input[@name='field68']");
785 Thread.sleep(100);
786 assertTrue(selenium.isTextPresent("Can only be numeric characters, parentheses, dashes"));
787
788 clearText("//input[@name='field67']");
789 selenium.type("//input[@name='field67']", "(123.00)");
790 selenium.focus("//input[@name='field68']");
791 Thread.sleep(100);
792 assertTrue(selenium.isTextPresent("Can only be numeric characters, parentheses, dashes"));
793
794 clearText("//input[@name='field67']");
795 selenium.type("//input[@name='field67']", "(12-3)");
796 selenium.focus("//input[@name='field68']");
797 Thread.sleep(100);
798 assertTrue(! selenium.isTextPresent("Can only be numeric characters, parentheses, dashes"));
799
800 //---------------------------------------------Valid Chars Custom Text------------------------------//
801 clearText("//input[@name='field68']");
802 selenium.type("//input[@name='field68']", "123.123");
803 selenium.focus("//input[@name='field67']");
804 Thread.sleep(100);
805 assertTrue(selenium.isTextPresent("only 1 alpha character followed by a period and then followed by 1 number (a.8, b.0, etc)"));
806
807 clearText("//input[@name='field68']");
808 selenium.type("//input[@name='field68']", "a.b");
809 selenium.focus("//input[@name='field67']");
810 Thread.sleep(100);
811 assertTrue(selenium.isTextPresent("only 1 alpha character followed by a period and then followed by 1 number (a.8, b.0, etc)"));
812
813 clearText("//input[@name='field68']");
814 selenium.type("//input[@name='field68']", "123 qwe");
815 selenium.focus("//input[@name='field67']");
816 Thread.sleep(100);
817 assertTrue(selenium.isTextPresent("only 1 alpha character followed by a period and then followed by 1 number (a.8, b.0, etc)"));
818
819 clearText("//input[@name='field68']");
820 selenium.type("//input[@name='field68']", "5.a");
821 selenium.focus("//input[@name='field67']");
822 Thread.sleep(100);
823 assertTrue(selenium.isTextPresent("only 1 alpha character followed by a period and then followed by 1 number (a.8, b.0, etc)"));
824
825 clearText("//input[@name='field68']");
826 selenium.type("//input[@name='field68']", "a.0,b.4");
827 selenium.focus("//input[@name='field67']");
828 Thread.sleep(100);
829 assertTrue(selenium.isTextPresent("only 1 alpha character followed by a period and then followed by 1 number (a.8, b.0, etc)"));
830
831
832 clearText("//input[@name='field68']");
833 selenium.type("//input[@name='field68']", "a.0");
834 selenium.focus("//input[@name='field67']");
835 Thread.sleep(100);
836 assertTrue(! selenium.isTextPresent("only 1 alpha character followed by a period and then followed by 1 number (a.8, b.0, etc)"));
837 }
838
839 @After
840 public void tearDown() throws Exception {
841 selenium.stop();
842 }
843
844 public void clearText(String field) throws Exception {
845 selenium.focus(field);
846 selenium.type(field, "");
847 Thread.sleep(100);
848 }
849 }