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.demo.lookupviews.lookup.multivalue;
017    
018    import edu.samplu.common.SmokeTestBase;
019    import org.junit.Test;
020    
021    /**
022     * @author Kuali Rice Team (rice.collab@kuali.org)
023     */
024    public class DemoLookUpMultiValueSmokeTest extends SmokeTestBase {
025    
026        /**
027         * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewMultipleValuesSelectLimit&hideReturnLink=true
028         */
029        public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewMultipleValuesSelectLimit&hideReturnLink=true";
030        
031        /**
032         *  lookupCriteria[number]
033         */
034        private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
035        
036        /**
037         *  Search
038         */
039        private static final String SEARCH="Search";
040        
041        /**
042         * Clear Values
043         */
044        private static final String CLEAR_VALUES="Clear Values";
045        
046        /**
047         * table table-condensed table-bordered uif-tableCollectionLayout dataTable
048         */
049        private static final String TABLE_ROW_SIX_XPATH="//table[@class='table table-condensed table-bordered uif-tableCollectionLayout dataTable']/tbody/tr[6]";
050        
051        /**
052         * Clear Values
053         */
054        private static final String FAILURE_MESSAGE="Results are not restricted to 5 rows.";
055        
056        @Override
057        public String getBookmarkUrl() {
058            return BOOKMARK_URL;
059        }
060    
061        @Override
062        protected void navigate() throws Exception {
063            waitAndClickById("Demo-DemoLink", "");
064            waitAndClickByLinkText("Lookup Multi Value");
065        }
066    
067        protected void testLookUpMultiValue() throws InterruptedException {
068            waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a1");
069            waitAndClickButtonByText(SEARCH);
070            Thread.sleep(3000);
071            assertElementPresentByXpath("//a[contains(text(), 'a1')]");
072            waitAndClickButtonByText(CLEAR_VALUES);
073            waitAndClickButtonByText(SEARCH);
074            Thread.sleep(3000);
075            if(isElementPresentByXpath(TABLE_ROW_SIX_XPATH)){
076                fail(FAILURE_MESSAGE);
077            }
078        }
079    
080        @Test
081        public void testLookUpMultiValueBookmark() throws Exception {
082            testLookUpMultiValue();
083            passed();
084        }
085    
086        @Test
087        public void testLookUpMultiValueNav() throws Exception {
088            testLookUpMultiValue();
089            passed();
090        }
091    }