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.krad.compview; 017 018 import static org.junit.Assert.assertNotSame; 019 020 import edu.samplu.common.Failable; 021 import edu.samplu.common.ITUtil; 022 import edu.samplu.common.WebDriverLegacyITBase; 023 024 /** 025 * Tests the Component section in Rice. 026 * 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029 public abstract class DeleteSubCollectionLineAbstractSmokeTestBase extends WebDriverLegacyITBase { 030 031 /** 032 * /kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91 033 */ 034 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91"; 035 036 /** 037 * list4[0].subList[0].field1 038 */ 039 public static final String FIELD_ELEMENT_NAME = "list4[0].subList[0].field1"; 040 041 /** 042 * Nav tests start at {@link edu.samplu.common.ITUtil#PORTAL}. Bookmark Tests should override and return {@link DeleteSubCollectionLineAbstractSmokeTestBase#BOOKMARK_URL} 043 * {@inheritDoc} 044 * @return 045 */ 046 @Override 047 public String getTestUrl() { 048 return ITUtil.PORTAL; 049 } 050 051 protected void navigation() throws Exception { 052 waitAndClickKRAD(); 053 waitAndClickByXpath(KITCHEN_SINK_XPATH); 054 switchToWindow(KUALI_UIF_COMPONENTS_WINDOW_XPATH); 055 } 056 057 protected void testDeleteSubCollectionLineNav(Failable failable) throws Exception { 058 navigation(); 059 testDeleteSubCollectionLine(); 060 passed(); 061 } 062 063 protected void testDeleteSubCollectionLineBookmark(Failable failable) throws Exception { 064 testDeleteSubCollectionLine(); 065 passed(); 066 } 067 068 protected void testDeleteSubCollectionLine() throws Exception { 069 // click on collections page link 070 waitAndClickByLinkText(COLLECTIONS_LINK_TEXT); 071 Thread.sleep(5000); 072 073 // wait for collections page to load by checking the presence of a sub collection line item 074 waitForElementPresentByName(FIELD_ELEMENT_NAME); 075 076 // change a value in the line to be deleted 077 waitAndTypeByName(FIELD_ELEMENT_NAME, "selenium"); 078 079 // click the delete button 080 waitAndClickById("subCollection1_line0_del_line0_line0"); 081 Thread.sleep(2000); 082 083 // confirm that the input box containing the modified value is not present 084 for (int second = 0;; second++) { 085 if (second >= waitSeconds)fail(TIMEOUT_MESSAGE); 086 087 try { 088 if (!"selenium".equals(waitAndGetAttributeByName(FIELD_ELEMENT_NAME, "value"))) 089 break; 090 } catch (Exception e) {} 091 092 Thread.sleep(1000); 093 } 094 095 // verify that the value has changed for the input box in the line that has replaced the deleted one 096 assertNotSame("selenium", waitAndGetAttributeByName(FIELD_ELEMENT_NAME, "value")); 097 } 098 }