View Javadoc
1   /**
2    * Copyright 2005-2016 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 LibraryValidationCaseConstraintsAft extends WebDriverLegacyITBase {
27  
28      /**
29       * /kr-krad/kradsampleapp?viewId=Demo-CaseConstraintView&methodToCall=start
30       */
31      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CaseConstraintView&methodToCall=start";
32  
33      @Override
34      protected String getBookmarkUrl() {
35          return BOOKMARK_URL;
36      }
37  
38      @Override
39      protected void navigate() throws Exception {
40          waitAndClickLibraryLink();
41          waitAndClickByLinkText("Validation");
42          waitAndClickByLinkText("Case Constraint");
43      }
44  
45      protected void testValidationCaseConstraintsBasic() throws Exception {
46          waitAndClickByLinkText("Basic Examples");
47  
48          //Scenario-1
49          waitAndClickByXpath("//input[@type='radio' and @value='case1']");
50          waitAndTypeByName("inputField1","");
51          waitAndTypeByName("inputField2","");
52          isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
53        
54          //Scenario-2
55          waitAndClickByXpath("//input[@type='radio' and @value='case2']");
56          waitAndTypeByName("inputField1","a_+");
57          waitAndTypeByName("inputField2","");
58          fireMouseOverEventByName("inputField1");
59          isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
60         
61          //Scenario-3
62          waitAndClickByXpath("//input[@type='radio' and @value='case3']");
63          waitAndTypeByName("inputField2","567823");
64          waitAndTypeByName("inputField1","");
65          fireMouseOverEventByName("inputField2");
66          isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
67         
68          //Scenario-4
69          waitAndClickByXpath("//input[@type='radio' and @value='case4']");
70          waitAndTypeByName("inputField3","a");
71          waitAndTypeByName("inputField4","");
72          waitAndTypeByName("inputField3","");
73          fireMouseOverEventByName("inputField4");
74          isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
75      }
76      
77      protected void testValidationCaseConstraintsNested() throws Exception {
78          waitAndClickByLinkText("Nested Example");
79         
80          //Scenario-1
81          waitAndTypeByName("inputField5","a");
82          waitAndTypeByName("inputField6","");
83          String id = waitAndTypeByName("inputField7","").getAttribute("id");
84          fireEvent("inputField7", "blur");
85          fireMouseOverEventByName("inputField7");
86          Thread.sleep(1000);
87          assertTrue(findElement(By.id(id)).getAttribute("class").contains("error"));
88      }
89      
90      @Test
91      public void testValidationCaseConstraintsBookmark() throws Exception {
92          testValidationCaseConstraintsBasic();
93          testValidationCaseConstraintsNested();
94          passed();
95      }
96  
97      @Test
98      public void testValidationCaseConstraintsNav() throws Exception {
99          testValidationCaseConstraintsBasic();
100         testValidationCaseConstraintsNested();
101         passed();
102     }
103 }