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.krad.configview; 017 018 import org.kuali.rice.testtools.common.JiraAwareFailable; 019 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 020 import org.openqa.selenium.By; 021 import org.openqa.selenium.WebElement; 022 023 import java.util.List; 024 025 /** 026 * Tests the Component section in Rice. 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030 public abstract class ConfigurationTestViewAftBase extends WebDriverLegacyITBase { 031 032 /** 033 * "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start"; 034 */ 035 public static final String BOOKMARK_URL = "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start"; 036 037 /** bean id prefix in used in view */ 038 private String idPrefix = "ConfigurationTestView-ProgressiveRender-"; 039 040 /** bean id suffix for add line controls */ 041 String addLineIdSuffix = "InputField_add_control"; 042 043 044 @Override 045 protected String getBookmarkUrl() { 046 return BOOKMARK_URL; 047 } 048 049 protected void navigation() throws InterruptedException { 050 waitAndClickKRAD(); 051 waitAndClickByXpath("(//a[text()='Configuration Test View'])"); 052 switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE); 053 waitForTitleToEqualKualiPortalIndex(); 054 } 055 056 protected void testConfigurationTestViewNav(JiraAwareFailable failable) throws Exception { 057 navigation(); 058 testConfigurationTestView(idPrefix); 059 testAddLineWithSpecificTime(idPrefix, addLineIdSuffix); 060 testAddLineWithAllDay(idPrefix, addLineIdSuffix); 061 testAddLineAllDay(idPrefix, addLineIdSuffix); 062 passed(); 063 } 064 065 protected void testConfigurationTestViewBookmark(JiraAwareFailable failable) throws Exception { 066 testConfigurationTestView(idPrefix); 067 testAddLineWithSpecificTime(idPrefix, addLineIdSuffix); 068 testAddLineWithAllDay(idPrefix, addLineIdSuffix); 069 testAddLineAllDay(idPrefix, addLineIdSuffix); 070 passed(); 071 } 072 073 protected void testAddLineWithSpecificTime(String idPrefix, String addLineIdSuffix) throws Exception { 074 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']"); 075 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix); 076 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']"; 077 String inputTime = "7:06"; 078 waitAndTypeByXpath(startTimeId, inputTime); 079 String amPmSelectLocator = "//*[@id='" + idPrefix + "StartTimeAmPm" + addLineIdSuffix + "']"; 080 selectByXpath(amPmSelectLocator, "PM"); 081 assertEquals("PM", waitAndGetAttributeByXpath(amPmSelectLocator, "value")); 082 Thread.sleep(5000); //allow for ajax refresh 083 waitAndClickButtonByText("add"); 084 Thread.sleep(5000); //allow for line to be added 085 086 //confirm that line has been added 087 assertTrue("line (//input[@value='7:06'])is not present", isElementPresentByXpath("//input[@value='7:06']")); 088 } 089 090 protected void testAddLineWithAllDay(String idPrefix, String addLineIdSuffix) throws Exception { 091 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']"); 092 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix); 093 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']"; 094 String inputTime = "5:20"; 095 waitAndTypeByXpath(startTimeId, inputTime); 096 String allDayId = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']"; 097 waitAndClickByXpath(allDayId); 098 checkForIncidentReport(); 099 Thread.sleep(5000); //allow for ajax refresh 100 waitAndClickButtonByText("add"); 101 Thread.sleep(5000); //allow for line to be added 102 103 //confirm that line has been added 104 assertTrue("line (//input[@checked='checked'])is not present", isElementPresentByXpath("//input[@checked='checked']")); 105 } 106 107 protected void testAddLineAllDay(String idPrefix, String addLineIdSuffix) throws Exception { 108 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']"); 109 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix); 110 String allDayId = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']"; 111 waitAndClickByXpath(allDayId); 112 checkForIncidentReport(); 113 Thread.sleep(5000); //allow for ajax refresh 114 waitAndClickButtonByText("add"); 115 Thread.sleep(5000); //allow for line to be added 116 117 //confirm that another line has been added (by checking the number of delete buttons) 118 WebElement table = findElement(By.id("ConfigurationTestView-ProgressiveRender-TimeInfoSection_disclosureContent")); 119 List<WebElement> columns = findElements(By.xpath("//button[contains(text(), 'delete')]"), table); 120 assertEquals("line was not added", 3, columns.size()); 121 122 } 123 124 /** 125 * verify that add line controls are present 126 */ 127 protected void confirmAddLineControlsPresent(String idPrefix, String addLineIdSuffix) { 128 String[] addLineIds = {"StartTime", "StartTimeAmPm", "AllDay"}; 129 130 for (String id : addLineIds) { 131 String tagId = "//*[@id='" + idPrefix + id + addLineIdSuffix + "']"; 132 assertTrue("Did not find id " + tagId, isElementPresentByXpath(tagId)); 133 } 134 } 135 136 }