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 edu.sampleu.krad.validationmessagesview;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20  
21  /**
22   * Tests the Component section in Rice.
23   *
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class ServerSideTestViewAft extends WebDriverLegacyITBase {
27  
28      /**
29       * "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91";
30       */
31      public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=Demo-ValidationServerSide&methodToCall=start";
32      
33      private static final String ERROR_ELEMENT_XPATH="//div[@class='uif-inputField uif-boxLayoutVerticalItem clearfix uif-hasError']";
34  
35      @Override
36      protected String getBookmarkUrl() {
37          return BOOKMARK_URL;
38      }
39  
40      protected void navigate() throws InterruptedException {
41          waitAndClickKRAD();
42          waitAndClickByLinkText("ServerSide Constraint Validation Demo");
43          switchToWindow("Kuali :: Validation Server-side Test View");               
44      }
45  
46      //Code for KRAD Test Package.
47      protected void testServerSideTestView() throws Exception {
48        
49         //MinMax length and value  and Required Constraint
50         waitAndTypeByName("field9","a");
51         waitAndTypeByName("field10","1");
52         waitAndClickByXpath("//button[@id='usave']");
53         waitForTextPresent("MinMax Length test: Must be between 2 and 5 characters long");
54         assertTextPresent("MinMax Value test: Value must be greater than 2 and no more than 50");
55         assertTextPresent(new String[]{"Required constraint", "4 errors"});
56         assertElementPresentByXpath("//div[@class='uif-inputField uif-boxLayoutHorizontalItem uif-hasError']");
57         fireMouseOverEventByName("field3");
58         waitForTextPresent("Field Label is a required field.");
59         fireMouseOverEventByName("field4");
60         waitForTextPresent("Radio is a required field.");
61         fireMouseOverEventByName("field5");
62         waitForTextPresent("Select is a required field.");
63         
64         //PreRequisite constraint
65  //       waitForElementPresentByXpath("//input[@name='field7' and @disabled]");
66  //       waitAndClickByXpath("//input[@type='checkbox' and @name='booleanField']");
67  //       if(isElementPresentByXpath("//input[@name='field7' and @disabled]")) {
68  //           fail("PreRequisite Constraint isn't working !");
69  //       }
70         
71         //MustOccurs constraint
72         waitAndTypeByName("field14","a");
73         waitAndClickByXpath("//button[@id='usave']");
74         Thread.sleep(4000);
75         
76         //Case constraint
77         waitAndClickByXpath("//input[@name='field24' and @value='case1']");
78         waitAndClickByXpath("//button[@id='usave']");
79         waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field25']");
80         waitAndClickByXpath("//input[@name='field24' and @value='case2']");
81         waitAndClickByXpath("//button[@id='usave']");
82         waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field25']");
83         waitAndTypeByName("field25","123@#");
84         waitAndClickByXpath("//button[@id='usave']");
85         waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field25']");
86         fireMouseOverEventByName("field25");
87         waitForTextPresent("  Can only be alphanumeric characters");
88         waitAndTypeByName("field26","1234");
89         waitAndClickByXpath("//input[@name='field24' and @value='case3']");
90         waitAndClickByXpath("//button[@id='usave']");
91         waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field26']");
92         fireMouseOverEventByName("field26");
93         waitForTextPresent("  Value cannot be greater than 500");
94         waitForTextPresent("  Must be at most 3 characters");
95         waitAndTypeByName("field31","as");
96         waitAndTypeByName("field32","asd");
97         waitAndClickByXpath("//button[@id='usave']");
98         waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field33']");
99         
100        //All remaining constraint
101        waitAndTypeByName("field50","1111.111");
102        waitAndTypeByName("field51","#1L");
103        waitAndTypeByName("field77","1.1");
104        waitAndTypeByName("field52","asdfasdf");
105        waitAndTypeByName("field53","deep");
106        waitAndTypeByName("field54","aad.@c");
107        waitAndTypeByName("field84","www.kuali.org");
108        waitAndTypeByName("field55","asd");
109        waitAndTypeByName("field75","2014-04-04");
110        waitAndTypeByName("field82","13");
111        waitAndTypeByName("field83","24");
112        waitAndTypeByName("field57","1599");
113        waitAndTypeByName("field58","0");
114        waitAndTypeByName("field61","360001");
115        waitAndTypeByName("field62","@#");
116        waitAndTypeByName("field63","@/");
117        waitAndTypeByName("field64","@#12");
118        waitAndTypeByName("field65","a s");
119        waitAndTypeByName("field66","d");
120        waitAndTypeByName("field67","asd");
121        waitAndTypeByName("field68","1.a");
122        waitAndClickByXpath("//button[@id='usave']");
123        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field50']");
124        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field51']");
125        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field77']");
126        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field52']");
127        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field53']");
128        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field54']");
129        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field84']");
130        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field55']");
131        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field75']");
132        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field82']");
133        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field83']");
134        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field57']");
135        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field58']");
136        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field61']");
137        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field62']");
138        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field63']");
139        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field64']");
140        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field65']");
141        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field66']");
142        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field67']");
143        waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field68']");
144 
145     }
146 
147     @Test
148     public void testServerSideTestViewBookmark() throws Exception {
149         testServerSideTestView();
150         passed();
151     }
152 
153     @Test
154     public void testServerSideTestViewNav() throws Exception {
155         testServerSideTestView();
156         passed();
157     }
158 }