View Javadoc

1   /*
2    * Copyright 2011 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/ecl1.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.samplu.travel.krad.test;
17  
18  import static org.junit.Assert.*;
19  
20  import org.junit.Test;
21  import org.openqa.selenium.By;
22  import org.openqa.selenium.WebElement;
23  
24  import edu.samplu.common.UpgradedSeleniumITBase;
25  
26  /**
27   * Test verifies updates in Totals at client side.
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class CollectionTotallingIT extends UpgradedSeleniumITBase {
32  
33      @Test
34      public void testCollectionTotalling() throws InterruptedException {
35          
36          //Scenario Asserts Changes in Total at client side
37          assertEquals("Total: 419", driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")).getText());
38          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1]  input[name='list1[0].field1']")).clear();
39          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1]  input[name='list1[0].field1']")).sendKeys("10");
40          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")).click();
41          Thread.sleep(5000);
42          assertEquals("Total: 424", driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")).getText());
43    
44          
45          
46          //Scenario Asserts Changes in Total at client side on keyUp
47          assertEquals("Total: 419", driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).getText());
48          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']")).clear();        
49          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']")).sendKeys("9");
50          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).click();
51          Thread.sleep(5000);
52          assertEquals("Total: 423", driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).getText());
53          
54          
55          //Asserts absence of Total in 2nd column at the footer for Demonstrating totaling on only some columns 
56          assertEquals("", driver.findElement(By.xpath("//div[3]/div[3]/table/tfoot/tr/th[2]")).getText());
57          //Asserts Presence of Total in 2nd column at the footer for Demonstrating totaling on only some columns 
58          assertEquals("Total: 369", driver.findElement(By.xpath("//div[3]/div[3]/table/tfoot/tr/th[3]/div/fieldset/div/div[2]/div[2]")).getText());
59        
60          
61          //Asserts Presence of Total in left most column only being one with no totaling itself 
62          assertEquals("Total:", driver.findElement(By.id("u100213_span")).getText());
63          assertEquals("419", driver.findElement(By.xpath("//div[4]/div[3]/table/tfoot/tr/th[2]/div/fieldset/div/div[2]/div[2]")).getText());
64  
65          //Asserts changes in value in Total and Decimal for Demonstrating multiple types of calculations for a single column (also setting average to 3 decimal places to demonstrate passing data to calculation function) 
66          assertEquals("Total: 382", driver.findElement(By.xpath("//div[2]/div/fieldset/div/div[2]/div[2]")).getText());
67          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']")).clear();
68          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']")).sendKeys("11");
69          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).click();
70          Thread.sleep(5000);
71          assertEquals("Total: 385", driver.findElement(By.xpath("//div[2]/div/fieldset/div/div[2]/div[2]")).getText());
72         
73         // Assert changes in Decimal..
74          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']")).clear();
75          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']")).sendKeys("15.25");
76          driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).click();
77          Thread.sleep(5000);
78          assertEquals("Page Average: 11.917", driver.findElement(By.xpath("//div[2]/fieldset/div/div[2]/div")).getText());
79         
80      }
81  
82      /**
83       * This overridden method ...
84       * 
85       * @see edu.samplu.common.UpgradedSeleniumITBase#getTestUrl()
86       */
87      @Override
88      public String getTestUrl() {
89          //Returns "Group Totalling" url
90          return "/kr-krad/uicomponents?viewId=Demo-CollectionTotaling&methodToCall=start";
91      }
92  
93  }