001/**
002 * Copyright 2005-2016 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 */
016package org.kuali.rice.krad.demo.uif.library.widgets;
017
018import org.junit.Test;
019import org.kuali.rice.krad.demo.uif.library.LibraryBase;
020import org.openqa.selenium.By;
021import org.openqa.selenium.WebElement;
022
023/**
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026public class LibraryWidgetsQuickFinderAft extends LibraryBase {
027
028    /**
029     * /kr-krad/kradsampleapp?viewId=Demo-QuickFinderView
030     */
031    public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-QuickFinderView";
032    
033    @Override
034    protected String getBookmarkUrl() {
035        return BOOKMARK_URL;
036    }
037
038    @Override
039    protected void navigate() throws Exception {
040        navigateToLibraryDemo("Widgets", "QuickFinder");
041    }
042
043    protected void testWidgetsQuickFinderLookUp() throws Exception {
044        waitAndClickByXpath("//section[@id='Demo-QuickFinder-Example1']/div/div/div/button");
045        gotoLightBox();
046
047        /* test nested quickfinder - start */
048        waitAndClick(By.cssSelector("button[id$='_quickfinder_act']"));
049        waitAndClickButtonByExactText("Search");
050        waitAndClickByLinkText("return value");
051        /* test nested quickfinder - end */
052
053        waitAndClickButtonByExactText("Search");
054        waitAndClickByLinkText("return value");
055    }
056
057    protected void testWidgetDirectQuickFinderLookUpReturnByScript() throws Exception { 
058        waitAndClickByLinkText("Lookup (Return by script)");
059        waitAndClickByXpath("//section[@id='Demo-QuickFinder-Example2']/div/div/div/button");
060        gotoLightBox();
061        waitAndClickButtonByExactText("Search");
062        waitAndClickByLinkText("return value");
063        selectTopFrame();
064    }
065    
066    protected void testWidgetDirectQuickFinderLookUpOverriddenLinkt() throws Exception {        
067        waitAndClickByLinkText("Lookup (Overridden link)");
068        waitAndTypeByName("inputField14","fred");
069    }
070    
071    protected void testWidgetDirectQuickFinderLookUpAditionalParameter() throws Exception {
072        waitAndClickByLinkText("Lookup (with additional parameters)");
073        waitAndClickByXpath("//section[@id='Demo-QuickFinder-Example4']/div/div/div/button");
074        gotoLightBox();
075        waitAndClickButtonByExactText("Search");
076        waitAndClickByLinkText("return value");
077    }
078 
079    private void testAllQuickFinder() throws Exception {
080        testWidgetsQuickFinderLookUp();
081        testWidgetDirectQuickFinderLookUpReturnByScript();
082        testWidgetDirectQuickFinderLookUpOverriddenLinkt();
083        testWidgetDirectQuickFinderLookUpAditionalParameter();
084            passed();
085    }
086
087    @Test
088    public void testWidgetsQuickFinderBookmark() throws Exception {
089        testAllQuickFinder();
090    }
091
092    @Test
093    public void testWidgetsQuickFinderNav() throws Exception {
094        testAllQuickFinder();
095    }
096}