View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.demo.uif.library.validation;
17  
18  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
19  import org.junit.Test;
20  import org.openqa.selenium.By;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoValidationAlphaNumericConstraintsAft extends WebDriverLegacyITBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-AlphaNumericPatternConstraintView&methodToCall=start
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-AlphaNumericPatternConstraintView&methodToCall=start";
31  
32      /**
33       *  Can only be alpha characters, whitespace, newlines, periods, parentheses, forward slashes, double quotes, apostrophes, colons, semi-colons, question marks, exclaimation marks, dashes
34       */
35      private static final String ERROR_MSG= "  Can only be alphanumeric characters, whitespace, newlines, periods, parentheses, forward slashes, double quotes, apostrophes, colons, semi-colons, question marks, exclaimation marks, dashes ";
36      
37      @Override
38      protected String getBookmarkUrl() {
39          return BOOKMARK_URL;
40      }
41  
42      @Override
43      protected void navigate() throws Exception {
44          waitAndClickById("Demo-LibraryLink", "");
45          waitAndClickByLinkText("Validation");
46          waitAndClickByLinkText("AlphaNumeric Constraint");
47      }
48  
49      protected void testValidationAlphaNumericConstraints() throws Exception {
50           //Scenario-1
51           waitAndTypeByName("inputField1","_as");
52          waitAndClickLinkContainingText("Library Navigation");
53          fireMouseOverEventByName("inputField1");
54           isVisible(By.xpath("//div[@class='uif-clientMessageItems uif-clientErrorDiv']"));
55      }
56      
57      protected void testValidationAlphaNumericConstraintsFlags() throws Exception {
58          waitAndClickByLinkText("Flags");
59          
60          //Scenario-1
61          waitAndTypeByName("inputField2","as 1_4");
62          waitAndTypeByName("inputField3","a_s");
63          isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
64          waitAndTypeByName("inputField2","");
65          isNotVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
66      }
67      
68      protected void testValidationAlphaNumericConstraintsPreconfiguredBeans() throws Exception {
69          waitAndClickByLinkText("Preconfigured Bean(s)");
70          
71          //Scenario-1
72          waitAndTypeByName("inputField4","as#");
73          waitAndClickLinkContainingText("Library Navigation");
74          fireMouseOverEventByName("inputField4");
75          isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
76       }
77      
78      @Test
79      public void testValidationAlphaNumericConstraintsBookmark() throws Exception {
80          testValidationAlphaNumericConstraints();
81          testValidationAlphaNumericConstraintsFlags();
82          testValidationAlphaNumericConstraintsPreconfiguredBeans();
83          passed();
84      }
85  
86      @Test
87      public void testValidationAlphaNumericConstraintsNav() throws Exception {
88          testValidationAlphaNumericConstraints();
89          testValidationAlphaNumericConstraintsFlags();
90          testValidationAlphaNumericConstraintsPreconfiguredBeans();
91          passed();
92      }
93  }