001 /** 002 * Copyright 2005-2014 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.sampleu.travel; 017 018 import org.junit.Test; 019 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 020 021 /** 022 * Tests the Component section in Rice. 023 * 024 * @author Kuali Rice Team (rice.collab@kuali.org) 025 */ 026 public class CollectionTotallingAft extends WebDriverLegacyITBase { 027 028 /** 029 * "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91"; 030 */ 031 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=Demo-CollectionTotaling&methodToCall=start"; 032 033 @Override 034 protected String getBookmarkUrl() { 035 return BOOKMARK_URL; 036 } 037 038 protected void navigate() throws InterruptedException { 039 waitAndClickKRAD(); 040 waitAndClickByXpath(KUALI_COLLECTION_TOTALLING_XPATH); 041 switchToWindow(KUALI_COLLECTION_TOTALLING_WINDOW_XPATH); 042 } 043 044 //Code for KRAD Test Package. 045 protected void testCollectionTotalling() throws Exception { 046 //Scenario Asserts Changes in Total at client side 047 Integer preValue=Integer.parseInt(getTextByXpath("//div[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/span[@class='uif-message']")); 048 clearTextByXpath("//div[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']"); 049 waitAndTypeByXpath("//div[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']","0"); 050 waitAndClickByXpath("//div[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/span[@class='uif-message']"); 051 Integer postValue=Integer.parseInt(getTextByXpath("//div[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/span[@class='uif-message']")); 052 Thread.sleep(2000); 053 if(postValue>preValue) { 054 jiraAwareFail("Totalling not working !"); 055 } 056 057 //Scenario Asserts Changes in Total at client side on keyUp 058 Integer preValueClient=Integer.parseInt(getTextByXpath("//div[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/span[@class='uif-message']")); 059 clearTextByXpath("//div[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']"); 060 waitAndTypeByXpath("//div[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']","0"); 061 Integer postValueClient=Integer.parseInt(getTextByXpath("//div[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/span[@class='uif-message']")); 062 Thread.sleep(2000); 063 if(postValueClient>preValueClient) { 064 jiraAwareFail("Totalling not working !"); 065 } 066 067 //Totalling Flexibility 068 assertElementPresentByXpath("//div[@id='Demo-CollectionTotaling-Section3']/div[@role='grid']/table/tfoot/tr/th[3]/div/fieldset/div/div/span[@class='uif-message']"); 069 070 //Left Total Labels 071 assertElementPresentByXpath("//div[@id='Demo-CollectionTotaling-Section4']/div[@role='grid']/table/tfoot/tr/th/div/label"); 072 073 //Multiple Calculations 074 assertEquals("Page Total:",getTextByXpath("//div[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div/fieldset/div/div/label")); 075 assertEquals("Page Average:",getTextByXpath("//div[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[2]/fieldset/div/div/label")); 076 assertEquals("Page Min:",getTextByXpath("//div[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[3]/fieldset/div/div/label")); 077 assertEquals("Page Max:",getTextByXpath("//div[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[4]/fieldset/div/div/label")); 078 079 //Group Totaling 080 assertEquals("Group Total:",getTextByXpath("//div[@id='Demo-CollectionTotaling-Section7']/div[@role='grid']/table/tbody/tr[7]/td/div/label")); 081 } 082 083 @Test 084 public void testCollectionTotallingBookmark() throws Exception { 085 testCollectionTotalling(); 086 passed(); 087 } 088 089 @Test 090 public void testCollectionTotallingNav() throws Exception { 091 testCollectionTotalling(); 092 passed(); 093 } 094 }