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