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