1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.admin.test;
17
18 import static org.junit.Assert.assertEquals;
19 import static org.junit.Assert.assertTrue;
20
21 import org.apache.commons.lang.RandomStringUtils;
22 import org.apache.commons.lang.StringUtils;
23 import org.junit.After;
24 import org.junit.Before;
25 import org.junit.Test;
26
27 import com.thoughtworks.selenium.DefaultSelenium;
28 import com.thoughtworks.selenium.Selenium;
29
30
31
32
33
34
35 public class LocationPostCodeBlanketAppIT {
36 private Selenium selenium;
37 @Before
38 public void setUp() throws Exception {
39 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
40 selenium.start();
41 }
42
43 @Test
44 public void testPostalCode() throws Exception {
45 String remotePublicUrl = System.getProperty("remote.public.url");
46
47 if (StringUtils.endsWith(remotePublicUrl, "/")) {
48 remotePublicUrl = StringUtils.removeEnd(remotePublicUrl, "/");
49 }
50 selenium.open(remotePublicUrl);
51 assertEquals("Login", selenium.getTitle());
52 selenium.type("__login_user", "admin");
53 selenium.click("//input[@value='Login']");
54 selenium.waitForPageToLoad("30000");
55 assertEquals("Kuali Portal Index", selenium.getTitle());
56 selenium.click("link=Administration");
57 selenium.waitForPageToLoad("30000");
58 assertEquals("Kuali Portal Index", selenium.getTitle());
59 selenium.click("link=Postal Code");
60 selenium.waitForPageToLoad("30000");
61 assertEquals("Kuali Portal Index", selenium.getTitle());
62 selenium.selectFrame("iframeportlet");
63 selenium.click("//img[@alt='create new']");
64 selenium.waitForPageToLoad("30000");
65 String docId = selenium.getText("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
66 assertTrue(selenium.isElementPresent("methodToCall.cancel"));
67
68 selenium.type("//input[@id='document.documentHeader.documentDescription']", "Validation Test Postal Code");
69 selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + remotePublicUrl + "/kr/lookup.do;::::).anchor4");
70 selenium.waitForPageToLoad("30000");
71 selenium.type("code", "US");
72 selenium.click("//input[@name='methodToCall.search' and @value='search']");
73 selenium.waitForPageToLoad("30000");
74 selenium.click("link=return value");
75 selenium.waitForPageToLoad("30000");
76 selenium.type("//input[@id='document.newMaintainableObject.code']", RandomStringUtils.randomNumeric(5));
77 selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.state.StateBo!!).(((countryCode:document.newMaintainableObject.countryCode,code:document.newMaintainableObject.stateCode,))).((`document.newMaintainableObject.countryCode:countryCode,document.newMaintainableObject.stateCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + remotePublicUrl + "/kr/lookup.do;::::).anchor4");
78 selenium.waitForPageToLoad("30000");
79 selenium.click("//input[@name='methodToCall.search' and @value='search']");
80 selenium.waitForPageToLoad("30000");
81 selenium.click("//table[@id='row']/tbody/tr[4]/td[1]/a");
82 selenium.waitForPageToLoad("30000");
83 selenium.type("//input[@id='document.newMaintainableObject.cityName']", "Validation Test Postal Code1");
84 selenium.click("methodToCall.blanketApprove");
85 selenium.waitForPageToLoad("30000");
86 selenium.selectWindow("null");
87 selenium.click("//img[@alt='doc search']");
88 selenium.waitForPageToLoad("30000");
89 assertEquals("Kuali Portal Index", selenium.getTitle());
90 selenium.selectFrame("iframeportlet");
91 selenium.click("//input[@name='methodToCall.search' and @value='search']");
92 selenium.waitForPageToLoad("30000");
93 docId= "link=" + docId;
94
95 assertTrue(selenium.isElementPresent(docId));
96 if(selenium.isElementPresent(docId)){
97 assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
98 }else{
99 assertEquals(docId, selenium.getText("//table[@id='row']/tbody/tr[1]/td[1]"));
100 assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
101 }
102 }
103
104 @After
105 public void tearDown() throws Exception {
106 selenium.stop();
107 }
108
109 }