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.junit.Test;
19  
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.openqa.selenium.By;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class DemoValidationSimpleConstraintsAft extends WebDriverLegacyITBase {
27  
28      /**
29       * /kr-krad/kradsampleapp?viewId=Demo-SimpleConstraintView&methodToCall=start
30       */
31      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-SimpleConstraintView&methodToCall=start";
32     
33      @Override
34      protected String getBookmarkUrl() {
35          return BOOKMARK_URL;
36      }
37  
38      @Override
39      protected void navigate() throws Exception {
40          waitAndClickById("Demo-LibraryLink", "");
41          waitAndClickByLinkText("Validation");
42          waitAndClickByLinkText("Simple Constraints");
43      }
44  
45      protected void testValidationSimpleConstraintsRequired() throws Exception {
46          waitAndClickByLinkText("Required");
47  
48          assertFocusTypeBlurError("inputField1", "");
49          assertFocusTypeBlurError("inputField2", "");
50          assertFocusTypeBlurError("inputField3", "");
51      }
52      
53      protected void testValidationSimpleConstraintsMinMaxLength() throws Exception {
54          waitAndClickByLinkText("Min/Max Length");
55  
56          waitAndTypeByName("inputField4","deepmoteria");
57          Thread.sleep(1000);
58          assertEquals("deepm", findElement(By.name("inputField4")).getAttribute("value"));
59          assertFocusTypeBlurError("inputField5", "de");
60      }
61  
62      protected void testValidationSimpleConstraintsMinMaxValue() throws Exception {
63          waitAndClickByLinkText("Min/Max Value");
64  
65          assertFocusTypeBlurError("inputField6","21");
66          assertFocusTypeBlurError("inputField7","2");
67      }
68      
69      @Test
70      public void testValidationSimpleConstraintsBookmark() throws Exception {
71          testValidationSimpleConstraintsRequired();
72          testValidationSimpleConstraintsMinMaxLength();
73          testValidationSimpleConstraintsMinMaxValue();
74          passed();
75      }
76  
77      @Test
78      public void testValidationSimpleConstraintsNav() throws Exception {
79          testValidationSimpleConstraintsRequired();
80          testValidationSimpleConstraintsMinMaxLength();
81          testValidationSimpleConstraintsMinMaxValue();
82          passed();
83      }
84  }