View Javadoc

1   package edu.samplu.mainmenu.test;
2   
3   import junit.framework.Assert;
4   
5   import edu.samplu.common.ITUtil;
6   import edu.samplu.common.WebDriverLegacyITBase;
7   
8   import org.junit.Test;
9   import org.openqa.selenium.Alert;
10  import org.openqa.selenium.JavascriptExecutor;
11  import org.openqa.selenium.WebDriver.Window;
12  
13  import static junit.framework.Assert.assertTrue;
14  import static org.junit.Assert.assertTrue;
15  
16  /**
17   * test that after doc search, navigating to people flow maintenance view does not cause Javascript errors
18   * and therefore interfere with JS functionality like validation
19   *
20   * @author Kuali Rice Team (rice.collab@kuali.org)
21   */
22  public class DocSearchToAnotherViewWDIT extends WebDriverLegacyITBase {
23  
24      @Override
25      public void fail(String message) {
26          org.junit.Assert.fail(message);
27      }
28  
29      @Override
30      public String getTestUrl() {
31          return ITUtil.PORTAL;
32      }
33  
34  	@Test
35      /**
36       * test that after doc search, navigating to people flow maintenance view does not cause Javascript errors
37       * and therefore interfere with JS functionality like validation
38       */
39  	public void testDocSearchToAnotherView() throws Exception {
40  		waitAndClick("img[alt=\"doc search\"]");
41  		waitForPageToLoad();
42  		selectFrame("iframeportlet");
43  		waitAndClick("td.infoline > input[name=\"methodToCall.search\"]");
44  		waitForPageToLoad();
45  	//	selectFrame("relative=top");
46  		driver.switchTo().defaultContent();
47  		waitAndClickByLinkText("Main Menu");
48          waitForPageToLoad();
49  		//setSpeed("2000");
50  		waitAndClickByLinkText("People Flow");
51  		waitForPageToLoad();
52  		selectFrame("iframeportlet");
53  		waitAndClickByLinkText("Create New");
54  		waitForPageToLoad();
55  		fireEvent("document.documentHeader.documentDescription", "focus");
56  		waitAndTypeByName("document.documentHeader.documentDescription", "sample description");
57  		fireEvent("document.documentHeader.explanation", "focus");
58  		waitAndTypeByName("document.documentHeader.explanation", "sample explanation");		
59  //		((JavascriptExecutor)driver).executeScript("document.getElementById(\"uif-cancel\").focus();");
60  		waitAndClickByLinkText("Cancel");
61  		Thread.sleep(5000);
62  		final String text = "Form has unsaved data. Do you want to leave anyway?";
63  		Alert a=driver.switchTo().alert();
64  		Assert.assertTrue(a.getText().equals(text));
65  		a.dismiss();
66          passed();
67  	}
68  }