001 /*
002 * Copyright 2011 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl1.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.samplu.travel.krad.test;
017
018 import static org.junit.Assert.*;
019
020 import org.junit.Test;
021 import org.openqa.selenium.By;
022 import org.openqa.selenium.WebElement;
023
024 import edu.samplu.common.UpgradedSeleniumITBase;
025
026 /**
027 * Test verifies updates in Totals at client side.
028 *
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031 public class CollectionTotallingIT extends UpgradedSeleniumITBase {
032
033 @Test
034 public void testCollectionTotalling() throws InterruptedException {
035
036 //Scenario Asserts Changes in Total at client side
037 assertEquals("Total: 419", driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")).getText());
038 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();
039 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");
040 driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")).click();
041 Thread.sleep(5000);
042 assertEquals("Total: 424", driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")).getText());
043
044
045
046 //Scenario Asserts Changes in Total at client side on keyUp
047 assertEquals("Total: 419", driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).getText());
048 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();
049 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");
050 driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).click();
051 Thread.sleep(5000);
052 assertEquals("Total: 423", driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).getText());
053
054
055 //Asserts absence of Total in 2nd column at the footer for Demonstrating totaling on only some columns
056 assertEquals("", driver.findElement(By.xpath("//div[3]/div[3]/table/tfoot/tr/th[2]")).getText());
057 //Asserts Presence of Total in 2nd column at the footer for Demonstrating totaling on only some columns
058 assertEquals("Total: 369", driver.findElement(By.xpath("//div[3]/div[3]/table/tfoot/tr/th[3]/div/fieldset/div/div[2]/div[2]")).getText());
059
060
061 //Asserts Presence of Total in left most column only being one with no totaling itself
062 assertEquals("Total:", driver.findElement(By.id("u100213_span")).getText());
063 assertEquals("419", driver.findElement(By.xpath("//div[4]/div[3]/table/tfoot/tr/th[2]/div/fieldset/div/div[2]/div[2]")).getText());
064
065 //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)
066 assertEquals("Total: 382", driver.findElement(By.xpath("//div[2]/div/fieldset/div/div[2]/div[2]")).getText());
067 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();
068 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");
069 driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).click();
070 Thread.sleep(5000);
071 assertEquals("Total: 385", driver.findElement(By.xpath("//div[2]/div/fieldset/div/div[2]/div[2]")).getText());
072
073 // Assert changes in Decimal..
074 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();
075 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");
076 driver.findElement(By.cssSelector("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")).click();
077 Thread.sleep(5000);
078 assertEquals("Page Average: 11.917", driver.findElement(By.xpath("//div[2]/fieldset/div/div[2]/div")).getText());
079
080 }
081
082 /**
083 * This overridden method ...
084 *
085 * @see edu.samplu.common.UpgradedSeleniumITBase#getTestUrl()
086 */
087 @Override
088 public String getTestUrl() {
089 //Returns "Group Totalling" url
090 return "/kr-krad/uicomponents?viewId=Demo-CollectionTotaling&methodToCall=start";
091 }
092
093 }