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.main;
017    
018    import org.junit.Test;
019    import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020    import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
021    import org.kuali.rice.testtools.selenium.WebDriverUtils;
022    import org.openqa.selenium.Alert;
023    
024    /**
025     * test that after doc search, navigating to people flow maintenance view does not cause Javascript errors
026     * and therefore interfere with JS functionality like validation
027     *
028     * @author Kuali Rice Team (rice.collab@kuali.org)
029     */
030    public class DocSearchToAnotherViewAft extends WebDriverLegacyITBase {
031    
032        @Override
033        protected String getBookmarkUrl() {
034            return AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=Document%20Search&channelUrl=" + WebDriverUtils
035                    .getBaseUrlString()
036                    + "/kew/DocumentSearch.do?docFormKey=88888888&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
037        }
038    
039            @Test
040        /**
041         * test that after doc search, navigating to people flow maintenance view does not cause Javascript errors
042         * and therefore interfere with JS functionality like validation
043         */
044            public void testDocSearchToAnotherViewBookmark() throws Exception {
045                    waitAndClick("img[alt=\"doc search\"]");
046                    waitForPageToLoad();
047                    selectFrame("iframeportlet");
048                    waitAndClick("td.infoline > input[name=\"methodToCall.search\"]");
049            //      selectFrame("relative=top");
050                    driver.switchTo().defaultContent();
051                    waitAndClickByLinkText("Main Menu");
052                    waitAndClickByLinkText("People Flow");
053                    waitForPageToLoad();
054                    selectFrame("iframeportlet");
055                    waitAndClickByLinkText("Create New");
056                    waitForPageToLoad();
057                    fireEvent("document.documentHeader.documentDescription", "focus");
058                    waitAndTypeByName("document.documentHeader.documentDescription", "sample description");
059                    fireEvent("document.documentHeader.explanation", "focus");
060                    waitAndTypeByName("document.documentHeader.explanation", "sample explanation");         
061    //              ((JavascriptExecutor)driver).executeScript("document.getElementById(\"uif-cancel\").focus();");
062                    waitAndClickByLinkText("Cancel");
063                    Thread.sleep(5000);
064                    final String text = "Form has unsaved data. Do you want to leave anyway?";
065                    Alert a=driver.switchTo().alert();
066                    assertTrue(a.getText().equals(text));
067                    a.dismiss();
068            passed();
069            }
070    }