1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.travel.krad.test;
18
19 import com.thoughtworks.selenium.DefaultSelenium;
20 import org.junit.After;
21 import org.junit.Assert;
22 import org.junit.Before;
23 import org.junit.Ignore;
24 import org.junit.Test;
25 import org.kuali.rice.core.framework.resourceloader.SpringResourceLoader;
26 import org.kuali.rice.krad.uif.component.Component;
27 import org.kuali.rice.krad.uif.view.View;
28
29 import static junit.framework.Assert.*;
30
31
32
33
34
35
36 public class ConfigurationTestViewIT {
37 private DefaultSelenium selenium;
38
39 private String idPrefix = "ConfigurationTestView-ProgressiveRender-";
40
41 String addLineIdSuffix = "InputField_add_control";
42 @Before
43 public void setUp() throws Exception {
44 selenium = new DefaultSelenium("localhost", 4444, "*chrome", System.getProperty("remote.public.url"));
45 selenium.start();
46 }
47
48 @Test
49
50
51
52 public void testConfigurationTestView() throws Exception {
53 openConfigurationTestView();
54
55
56 String styleValue = selenium.getAttribute("//span[@id='" + idPrefix + "TextInputField_label_span']@style");
57
58 Assert.assertTrue(idPrefix + "textInputField label does not contain expected style", styleValue.replace(" ", "").contains(
59 "color:red"));
60
61
62 selenium.selectFrame("iframeportlet");
63
64 String refreshTextSelectLocator = "id=" + idPrefix + "RefreshTextField_control";
65 String[] options1 = selenium.getSelectOptions(refreshTextSelectLocator);
66 String dropDownSelectLocator = "id=" + idPrefix + "DropDown_control";
67 selenium.select(dropDownSelectLocator, "label=Vegetables");
68 selenium.click("//option[@value='Vegetables']");
69 Thread.sleep(3000);
70
71 String[] options2 = selenium.getSelectOptions(refreshTextSelectLocator);
72
73 assertFalse(options1[options1.length - 1].equalsIgnoreCase(options2[options2.length - 1]));
74
75 selenium.select(dropDownSelectLocator, "label=None");
76 Thread.sleep(3000);
77 assertEquals("true", selenium.getAttribute(refreshTextSelectLocator+ "@disabled"));
78
79 }
80
81
82
83
84 private void openConfigurationTestView() {
85 selenium.open("/kr-dev/portal.do");
86 selenium.type("name=__login_user", "admin");
87 selenium.click("css=input[type=\"submit\"]");
88 selenium.waitForPageToLoad("30000");
89 selenium.click("link=KRAD");
90 selenium.waitForPageToLoad("30000");
91 selenium.isElementPresent("link=Configuration Test View");
92 selenium.click("link=Configuration Test View");
93 selenium.waitForPageToLoad("30000");
94 }
95
96
97
98
99
100 @Test
101 public void testAddLineWithSpecificTime() throws Exception{
102 openConfigurationTestView();
103 confirmAddLineControlsPresent();
104
105 String startTimeId = "id=" +idPrefix + "StartTime" + addLineIdSuffix;
106 selenium.focus(startTimeId);
107 String inputTime = "7:06";
108 selenium.type(startTimeId, inputTime);
109
110 String amPmSelectLocator = "id=" + idPrefix + "StartTimeAmPm" + addLineIdSuffix;
111 selenium.click(amPmSelectLocator);
112 selenium.select(amPmSelectLocator, "label=PM");
113 assertEquals("PM", selenium.getSelectedLabel(amPmSelectLocator));
114
115 Thread.sleep(5000);
116 selenium.click("css=div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button");
117 Thread.sleep(5000);
118
119
120 assertTrue("line is not present", selenium.isElementPresent("//input[@value='7:06']"));
121 }
122
123
124
125
126 private void confirmAddLineControlsPresent() {
127 String[] addLineIds = {"StartTime", "StartTimeAmPm", "AllDay"};
128
129 for (String id: addLineIds) {
130 String tagId = "id=" + idPrefix + id + addLineIdSuffix;
131 assertTrue("Did not find id " + tagId, selenium.isElementPresent(tagId));
132 }
133 }
134
135
136
137
138
139 @Test
140 @Ignore("count rows through CSS or XPATH fails")
141 public void testAddLineAllDay() throws Exception{
142 openConfigurationTestView();
143 confirmAddLineControlsPresent();
144
145
146 String cssCountRows = "div#ConfigurationTestView-ProgressiveRender-TimeInfoSection.uif-group div#ConfigurationTestView-ProgressiveRender-TimeInfoSection_disclosureContent.uif-disclosureContent table tbody tr";
147 int rowCount = (selenium.getCssCount(cssCountRows)).intValue();
148
149 String allDayId = "id=" + idPrefix + "AllDay" + addLineIdSuffix;
150 selenium.focus(allDayId);
151 Thread.sleep(5000);
152 selenium.click(allDayId);
153 selenium.click("css=div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button");
154 Thread.sleep(5000);
155
156
157 assertEquals("line was not added", rowCount + 1, (selenium.getCssCount(cssCountRows)).intValue());
158 }
159
160
161 @After
162 public void tearDown() throws Exception {
163 selenium.stop();
164 }
165 }