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 @Test
47 @Ignore
48 public void testLeaveRequestPage() throws Exception {
49
50 HtmlPage leaveRequestPage = HtmlUnitUtil
51 .gotoPageAndLogin(getWebClient(), TkTestConstants.Urls.LEAVE_REQUEST_PAGE_URL);
52 Assert.assertNotNull("Leave Request page not found" + leaveRequestPage);
53
54
55 Assert.assertTrue("Page does not contain planned leave ", leaveRequestPage
56 .asText().contains("Send for Approval"));
57
58
59 Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage
60 .asText().contains("Approved Leave"));
61
62
63 Assert.assertTrue("Page does not contain approved leaves ", leaveRequestPage
64 .asText().contains("Disapprove"));
65
66 HtmlCheckBoxInput htmlElement = (HtmlCheckBoxInput) leaveRequestPage
67 .getElementByName("plannedLeaves[0].submit");
68 leaveRequestPage = (HtmlPage) htmlElement.setValueAttribute("true");
69
70 HtmlCheckBoxInput checkbox = (HtmlCheckBoxInput) HtmlUnitUtil
71 .getInputContainingText(leaveRequestPage,
72 "plannedLeaves[0].submit");
73 checkbox.setChecked(true);
74
75 HtmlElement elementSubmit = leaveRequestPage.getElementByName("Submit");
76 Assert.assertNotNull(elementSubmit);
77
78 HtmlUnitUtil.createTempFile(leaveRequestPage);
79
80 HtmlPage leaveRequestPage1 = elementSubmit.click();
81
82 HtmlUnitUtil.createTempFile(leaveRequestPage1);
83
84
85
86 Assert.assertTrue("Page does not contain Pending leave ", leaveRequestPage1
87 .asText().contains("Send for Approval"));
88
89 }
90
91 }