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      @Override
34      protected String getBookmarkUrl() {
35          return BOOKMARK_URL;
36      }
37  
38      protected void navigate() throws InterruptedException {
39          waitAndClickKRAD();
40          waitAndClickByLinkText("ServerSide Constraint Validation Demo");
41          switchToWindow("Kuali :: Validation Server-side Test View");               
42      }
43  
44      //Code for KRAD Test Package.
45      protected void testServerSideTestView() throws Exception {
46        
47         //MinMax length and value  and Required Constraint
48         waitAndTypeByName("field9","a");
49         waitAndTypeByName("field10","1");
50         waitAndClickByXpath("//button[@id='usave']");
51         Thread.sleep(4000);
52         assertTextPresent("MinMax Length test: Must be between 2 and 5 characters long");
53         assertTextPresent("MinMax Value test: Value must be greater than 2 and no more than 50");
54         assertTextPresent(new String[]{"Required constraint", "4 errors"});
55         
56         //PreRequisite constraint
57         waitForElementPresentByXpath("//input[@name='field7' and @disabled]");
58         waitAndClickByXpath("//input[@type='checkbox' and @name='booleanField']");
59         if(isElementPresentByXpath("//input[@name='field7' and @disabled]")) {
60             fail("PreRequisite Constraint isn't working !");
61         }
62         
63         //MustOccurs constraint
64         waitAndTypeByName("field14","a");
65         waitAndClickByXpath("//button[@id='usave']");
66         Thread.sleep(4000);
67  
68      }
69  
70      @Test
71      public void testServerSideTestViewBookmark() throws Exception {
72          testServerSideTestView();
73          passed();
74      }
75  
76      @Test
77      public void testServerSideTestViewNav() throws Exception {
78          testServerSideTestView();
79          passed();
80      }
81  }