001    package edu.samplu.mainmenu.test;
002    
003    import junit.framework.Assert;
004    
005    import edu.samplu.common.ITUtil;
006    import edu.samplu.common.WebDriverLegacyITBase;
007    
008    import org.junit.Test;
009    import org.openqa.selenium.Alert;
010    import org.openqa.selenium.JavascriptExecutor;
011    import org.openqa.selenium.WebDriver.Window;
012    
013    import static junit.framework.Assert.assertTrue;
014    import static org.junit.Assert.assertTrue;
015    
016    /**
017     * test that after doc search, navigating to people flow maintenance view does not cause Javascript errors
018     * and therefore interfere with JS functionality like validation
019     *
020     * @author Kuali Rice Team (rice.collab@kuali.org)
021     */
022    public class DocSearchToAnotherViewLegacyIT extends WebDriverLegacyITBase {
023        @Override
024        public String getTestUrl() {
025            return ITUtil.PORTAL;
026        }
027    
028            @Test
029        /**
030         * test that after doc search, navigating to people flow maintenance view does not cause Javascript errors
031         * and therefore interfere with JS functionality like validation
032         */
033            public void testDocSearchToAnotherView() throws Exception {
034                    waitAndClick("img[alt=\"doc search\"]");
035                    waitForPageToLoad();
036                    selectFrame("iframeportlet");
037                    waitAndClick("td.infoline > input[name=\"methodToCall.search\"]");
038                    waitForPageToLoad();
039            //      selectFrame("relative=top");
040                    driver.switchTo().defaultContent();
041                    waitAndClickByLinkText("Main Menu");
042            waitForPageToLoad();
043                    //setSpeed("2000");
044                    waitAndClickByLinkText("People Flow");
045                    waitForPageToLoad();
046                    selectFrame("iframeportlet");
047                    waitAndClickByLinkText("Create New");
048                    waitForPageToLoad();
049                    fireEvent("document.documentHeader.documentDescription", "focus");
050                    waitAndTypeByName("document.documentHeader.documentDescription", "sample description");
051                    fireEvent("document.documentHeader.explanation", "focus");
052                    waitAndTypeByName("document.documentHeader.explanation", "sample explanation");         
053                    ((JavascriptExecutor)driver).executeScript("document.getElementById(\"uif-cancel\").focus();");
054                    waitAndClickByLinkText("Cancel");
055                    Thread.sleep(5000);
056                    final String text = "Form has unsaved data. Do you want to leave anyway?";
057                    Alert a=driver.switchTo().alert();
058                    Assert.assertTrue(a.getText().equals(text));
059                    a.dismiss();
060            passed();
061            }
062    }