001    /**
002     * Copyright 2005-2011 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    
017    package edu.sampleu.admin;
018    
019    import org.junit.Test;
020    import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
021    import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
022    import org.kuali.rice.testtools.selenium.WebDriverUtils;
023    
024    /**
025     * test that repeated ajax refreshes work
026     * @author Kuali Rice Team (rice.collab@kuali.org)
027     */
028    public class AgendaEditRuleRefreshAft extends WebDriverLegacyITBase {
029    
030        public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL+"?channelTitle=Agenda%20Lookup&channelUrl="
031                + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
032                + "org.kuali.rice.krms.impl.repository.AgendaBo"
033                + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS
034                + "&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
035    
036        @Override
037        protected String getBookmarkUrl() {
038            return BOOKMARK_URL;
039        }
040    
041        @Override
042        protected void navigate() throws Exception {
043            waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT);
044            waitForPageToLoad();
045        }
046    
047        protected void testAgendaEditRuleRefresh() throws Exception {
048            selectFrameIframePortlet();
049            waitAndClickButtonByText("Search");
050            //        waitAndClickByXpath("//div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button[1]"); //  jiraAwareWaitAndClick("id=32");
051            waitAndClickByXpath("//a[@title='edit Agenda Definition with Agenda Id=T1000']",
052                    "Does user have edit permissions?"); // jiraAwareWaitAndClick("id=194_line0");
053            waitAndClickByXpath("//li/a[@class='agendaNode ruleNode']"); // jiraAwareWaitAndClick("//li[@id='473_node_0_parent_root']/a");
054            waitAndClickByXpath("//li/a[@class='agendaNode logicNode whenTrueNode']");
055            waitAndClickByLinkText("[-] collapse all");
056    
057            // click refresh  several times
058            for (int i = 0; i < 6; i++) {
059                for (int second = 0;; second++) {
060                    if (second >= waitSeconds)
061                        jiraAwareFail(TIMEOUT_MESSAGE);
062                    try {
063                        if (isElementPresent(".kr-refresh-button"))
064                            break;
065                    } catch (Exception e) {}
066                    Thread.sleep(1000);
067                }
068                waitAndClick("button.kr-refresh-button");
069            }
070            passed();
071        }
072    
073        /**
074         * test that repeated ajax refreshes work
075         */
076        @Test
077        public void testAgendaEditRuleRefreshBookmark() throws Exception {
078            testAgendaEditRuleRefresh();
079        }
080    
081        /**
082         * test that repeated ajax refreshes work
083         */
084        @Test
085        public void testAgendaEditRuleRefreshNav() throws Exception {
086            testAgendaEditRuleRefresh();
087        }
088    }
089