View Javadoc
1   /**
2    * Copyright 2005-2015 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.screenelement;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.kuali.rice.testtools.selenium.WebDriverUtils;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class StateBasedValidationClientTestsAft extends WebDriverLegacyITBase {
27  
28      /**
29       * /kr-krad/uicomponents?viewId=Demo-StateBasedValidation-Client&methodToCall=start
30       */
31      public static final String BOOKMARK_URL ="/kr-krad/uicomponents?viewId=Demo-StateBasedValidation-Client&methodToCall=start";
32  
33      @Override
34      protected String getBookmarkUrl() {
35          return BOOKMARK_URL;
36      }
37  
38      @Override
39      protected void navigate() throws InterruptedException {
40          waitAndClickKRAD();
41          waitAndClickByLinkText("State-based Validation (Client test)");
42          switchToWindow("Kuali :: State-based Validation client-side Test View");
43      }
44      
45      private void testStateBasedValidationClientTests() throws Exception{
46          //State 1
47          waitAndClickButtonByText("Check Form");
48          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasWarning' and @data-label='Field 1']");
49          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasWarning' and @data-label='Field 2']");
50          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 3']");
51          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 4']");
52          waitForElementPresentByXpath("//input[@maxlength='50']");
53          
54          //State 2
55          waitAndClickButtonByText("Change to State 2");
56          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 1']");
57          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 2']");
58          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 3']");
59          waitForElementPresentByXpath("//input[@maxlength='50']");
60      
61          //State 3
62          waitAndTypeByName("field5","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
63          waitAndClickButtonByText("Change to State 3");
64          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 2']");
65          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 4']");
66          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 5']");
67          fireMouseOverEventByName("field5");
68          waitForTextPresent("For State 3, Must be at most 25 characters");
69      
70          //State 4
71          waitAndClickButtonByText("Change to State 4");
72          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 2']");
73          waitForElementPresentByXpath("//div[@class='uif-inputField uif-inputField-labelTop uif-boxLayoutVerticalItem clearfix uif-hasError' and @data-label='Field 5']");
74          fireMouseOverEventByName("field5");
75          waitForTextPresent("For State 4, Must be at most 15 characters");
76      }
77      
78      @Test
79      public void testStateBasedValidationClientTestsBookmark() throws Exception {
80          testStateBasedValidationClientTests();
81          passed();
82      }
83  
84      @Test
85      public void testStateBasedValidationClientTestsNav() throws Exception {
86          testStateBasedValidationClientTests();
87          passed();
88      }
89      
90  }