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.WebDriverLegacyITBase;
20  
21  /**
22   * Tests the Component section in Rice.
23   *
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class CollectionTotallingAft 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-CollectionTotaling&methodToCall=start";
32  
33      @Override
34      protected String getBookmarkUrl() {
35          return BOOKMARK_URL;
36      }
37  
38      protected void navigate() throws InterruptedException {
39          waitAndClickKRAD();
40          waitAndClickByXpath(KUALI_COLLECTION_TOTALLING_XPATH);
41          switchToWindow(KUALI_COLLECTION_TOTALLING_WINDOW_XPATH);               
42      }
43  
44      //Code for KRAD Test Package.
45      protected void testCollectionTotalling() throws Exception {
46          //Scenario Asserts Changes in Total at client side
47          Integer preValue=Integer.parseInt(getTextByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p"));
48          clearTextByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']");
49          waitAndTypeByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']","0");
50          waitAndClickByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p");
51          Integer postValue=Integer.parseInt(getTextByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p"));
52          Thread.sleep(2000);
53          if(postValue>preValue) {
54              jiraAwareFail("Totalling not working !");
55          }        
56          
57          //Scenario Asserts Changes in Total at client side on keyUp
58          Integer preValueClient=Integer.parseInt(getTextByXpath("//section[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p"));
59          clearTextByXpath("//section[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']");
60          waitAndTypeByXpath("//section[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']","0");
61          Integer postValueClient=Integer.parseInt(getTextByXpath("//section[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p"));
62          Thread.sleep(2000);        
63          if(postValueClient>preValueClient) {
64              jiraAwareFail("Totalling not working !");
65          }  
66          
67          //Totalling Flexibility
68          assertElementPresentByXpath("//section[@id='Demo-CollectionTotaling-Section3']/div[@role='grid']/table/tfoot/tr/th[3]/div/fieldset/div/div/p");
69  
70          //Left Total Labels
71          assertElementPresentByXpath("//section[@id='Demo-CollectionTotaling-Section4']/div[@role='grid']/table/tfoot/tr/th/div/label");
72          
73          //Multiple Calculations
74          assertEquals("Page Total:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div/fieldset/div/div/label"));
75          assertEquals("Page Average:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[2]/fieldset/div/div/label"));
76          assertEquals("Page Min:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[3]/fieldset/div/div/label"));
77          assertEquals("Page Max:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[4]/fieldset/div/div/label"));
78          
79          //Group Totaling
80          assertEquals("Group Total:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section7']/div[@role='grid']/table/tbody/tr[7]/td/div/label"));
81      }
82  
83      @Test
84      public void testCollectionTotallingBookmark() throws Exception {
85          testCollectionTotalling();
86          passed();
87      }
88  
89      @Test
90      public void testCollectionTotallingNav() throws Exception {
91          testCollectionTotalling();
92          passed();
93      }
94  }