1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.lm.leave.web;
17
18 import junit.framework.Assert;
19
20 import org.junit.After;
21 import org.junit.Before;
22 import org.junit.Ignore;
23 import org.junit.Test;
24 import org.kuali.hr.test.KPMETestCase;
25 import org.kuali.hr.time.test.HtmlUnitUtil;
26 import org.kuali.hr.time.test.TkTestConstants;
27
28 import com.gargoylesoftware.htmlunit.NicelyResynchronizingAjaxController;
29 import com.gargoylesoftware.htmlunit.WebClient;
30 import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput;
31 import com.gargoylesoftware.htmlunit.html.HtmlElement;
32 import com.gargoylesoftware.htmlunit.html.HtmlPage;
33
34 public class LeaveRequestWebTest extends KPMETestCase {
35
36 @Before
37 public void setUp() throws Exception {
38 super.setUp();
39 }
40
41 @After
42 public void tearDown() throws Exception {
43 super.tearDown();
44 }
45
46 public void setWebClient(WebClient webClient) {
47 webClient.setJavaScriptEnabled(true);
48 webClient.setThrowExceptionOnScriptError(true);
49 webClient.setAjaxController(new NicelyResynchronizingAjaxController());
50 webClient.waitForBackgroundJavaScript(10000);
51 }
52
53 @Test
54 @Ignore
55 public void testLeaveRequestPage() throws Exception {
56
57 HtmlPage leaveRequestPage = HtmlUnitUtil
58 .gotoPageAndLogin(TkTestConstants.Urls.LEAVE_REQUEST_PAGE_URL);
59 Assert.assertNotNull("Leave Request page not found" + leaveRequestPage);
60
61
62 Assert.assertTrue("Page does not contain planned leave ", leaveRequestPage
63 .asText().contains("Send for Approval"));
64
65
66 Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage
67 .asText().contains("Approved Leave"));
68
69
70 Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage
71 .asText().contains("Disapprove"));
72
73 HtmlCheckBoxInput htmlElement = (HtmlCheckBoxInput) leaveRequestPage
74 .getElementByName("plannedLeaves[0].submit");
75 leaveRequestPage = (HtmlPage) htmlElement.setValueAttribute("true");
76
77 HtmlCheckBoxInput checkbox = (HtmlCheckBoxInput) HtmlUnitUtil
78 .getInputContainingText(leaveRequestPage,
79 "plannedLeaves[0].submit");
80 checkbox.setChecked(true);
81
82 HtmlElement elementSubmit = leaveRequestPage.getElementByName("Submit");
83 Assert.assertNotNull(elementSubmit);
84
85 HtmlUnitUtil.createTempFile(leaveRequestPage);
86
87 HtmlPage leaveRequestPage1 = elementSubmit.click();
88
89 HtmlUnitUtil.createTempFile(leaveRequestPage1);
90
91
92
93 Assert.assertTrue("Page does not contain Pending leave ", leaveRequestPage1
94 .asText().contains("Send for Approval"));
95
96 }
97
98 }