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