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 */
016package edu.sampleu.main;
017
018import org.junit.Test;
019import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
021import org.kuali.rice.testtools.selenium.WebDriverUtils;
022import 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 */
030public 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        jGrowl("Click Cancel");
063        waitAndClickByXpath("//div[@class='uif-footer clearfix']/button[contains(text(), 'Cancel')]");
064                Thread.sleep(5000);
065                final String text = "Form has unsaved data. Do you want to leave anyway?";
066                Alert a=driver.switchTo().alert();
067                assertTrue(a.getText().equals(text));
068                a.dismiss();
069        passed();
070        }
071}