001 /** 002 * Copyright 2005-2013 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/ecl2.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 com.thoughtworks.selenium.SeleneseTestBase; 019 import edu.samplu.common.SmokeTestBase; 020 import org.junit.Test; 021 022 /** 023 * Tests the Component section in Rice. 024 * 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027 public class CollectionTotallingSmokeTest extends SmokeTestBase { 028 029 /** 030 * "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91"; 031 */ 032 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=Demo-CollectionTotaling&methodToCall=start"; 033 034 @Override 035 protected String getBookmarkUrl() { 036 return BOOKMARK_URL; 037 } 038 039 protected void navigate() throws InterruptedException { 040 waitAndClickKRAD(); 041 waitAndClickByXpath(KUALI_COLLECTION_TOTALLING_XPATH); 042 switchToWindow(KUALI_COLLECTION_TOTALLING_WINDOW_XPATH); 043 } 044 045 //Code for KRAD Test Package. 046 protected void testCollectionTotalling() throws Exception { 047 //Scenario Asserts Changes in Total at client side 048 waitForElementPresent("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']"); 049 SeleneseTestBase.assertEquals("Total: 419", getText( 050 "div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")); 051 clearText("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1] input[name='list1[0].field1']"); 052 waitAndType("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1] input[name='list1[0].field1']","10"); 053 waitAndClick("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']"); 054 Thread.sleep(5000); 055 SeleneseTestBase.assertEquals("Total: 424", getText( 056 "div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")); 057 058 //Scenario Asserts Changes in Total at client side on keyUp 059 SeleneseTestBase.assertEquals("Total: 419", getText( 060 "div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")); 061 clearText("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']"); 062 waitAndType("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']","9"); 063 waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"); 064 Thread.sleep(5000); 065 SeleneseTestBase.assertEquals("Total: 423", getText( 066 "div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")); 067 068 //Asserts absence of Total in 2nd column at the footer for Demonstrating totaling on only some columns 069 SeleneseTestBase.assertEquals("", getTextByXpath("//div[3]/div[3]/table/tfoot/tr/th[2]")); 070 071 //Asserts Presence of Total in 2nd column at the footer for Demonstrating totaling on only some columns 072 SeleneseTestBase.assertEquals("Total: 369", getTextByXpath( 073 "//div[3]/div[3]/table/tfoot/tr/th[3]/div/fieldset/div/div[2]/div[2]")); 074 075 //Asserts Presence of Total in left most column only being one with no totaling itself 076 SeleneseTestBase.assertEquals("Total:", getTextByXpath("//*[@id='u100213_span']")); 077 SeleneseTestBase.assertEquals("419", getTextByXpath( 078 "//div[4]/div[3]/table/tfoot/tr/th[2]/div/fieldset/div/div[2]/div[2]")); 079 080 //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) 081 SeleneseTestBase.assertEquals("Total: 382", getTextByXpath("//div[2]/div/fieldset/div/div[2]/div[2]")); 082 clearText("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']"); 083 waitAndType("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']","11"); 084 waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"); 085 Thread.sleep(5000); 086 SeleneseTestBase.assertEquals("Total: 385", getTextByXpath("//div[2]/div/fieldset/div/div[2]/div[2]")); 087 088 // Assert changes in Decimal.. 089 clearText("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']"); 090 waitAndType("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']","15.25"); 091 waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"); 092 Thread.sleep(5000); 093 SeleneseTestBase.assertEquals("Page Average: 11.917", getTextByXpath("//div[2]/fieldset/div/div[2]/div")); 094 } 095 096 @Test 097 public void testCollectionTotallingBookmark() throws Exception { 098 testCollectionTotalling(); 099 passed(); 100 } 101 102 @Test 103 public void testCollectionTotallingNav() throws Exception { 104 testCollectionTotalling(); 105 passed(); 106 } 107 }