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 edu.samplu.common.ITUtil;
20 import edu.samplu.common.WebDriverLegacyITBase;
21
22 import org.junit.Assert;
23 import org.junit.Test;
24
25 import static junit.framework.Assert.*;
26
27
28
29
30
31
32 public class ConfigurationTestViewLegacyIT extends WebDriverLegacyITBase {
33 @Override
34 public String getTestUrl() {
35 return ITUtil.PORTAL;
36 }
37
38 private String idPrefix = "ConfigurationTestView-ProgressiveRender-";
39
40 String addLineIdSuffix = "InputField_add_control";
41
42
43
44
45
46 @Test
47 public void testConfigurationTestView() throws Exception {
48 openConfigurationTestView();
49
50 selectFrame("iframeportlet");
51
52 String styleValue = getAttributeByXpath("//span[@id='" + idPrefix + "TextInputField_label_span']","style");
53
54 Assert.assertTrue(idPrefix + "textInputField label does not contain expected style", styleValue.replace(" ", "").contains(
55 "color:red"));
56
57
58 String refreshTextSelectLocator = "//select[@id='" + idPrefix + "RefreshTextField_control']";
59 String[] options1 = getSelectOptionsByXpath(refreshTextSelectLocator);
60 String dropDownSelectLocator = "//select[@id='" + idPrefix + "DropDown_control']";
61 selectByXpath(dropDownSelectLocator, "Vegetables");
62 Thread.sleep(3000);
63
64 String[] options2 = getSelectOptionsByXpath(refreshTextSelectLocator);
65
66 assertFalse("Field 1 selection did not change Field 2 options https://jira.kuali.org/browse/KULRICE-8163 Configuration Test View Conditional Options doesn't change Field 2 options based on Field 1 selection", options1[options1.length - 1].equalsIgnoreCase(options2[options2.length - 1]));
67
68 selectByXpath(dropDownSelectLocator, "None");
69 Thread.sleep(3000);
70 assertEquals("true", getAttributeByXpath(refreshTextSelectLocator, "disabled"));
71 passed();
72 }
73
74
75
76
77 private void openConfigurationTestView() throws InterruptedException {
78 waitAndClickByLinkText("KRAD");
79 waitAndClickByLinkText("Configuration Test View");
80 waitForPageToLoad();
81 }
82
83
84
85
86
87 @Test
88 public void testAddLineWithSpecificTime() throws Exception{
89 openConfigurationTestView();
90
91 selectFrame("iframeportlet");
92
93 confirmAddLineControlsPresent();
94
95 String startTimeId = "//*[@id='" +idPrefix + "StartTime" + addLineIdSuffix + "']";
96
97 String inputTime = "7:06";
98 waitAndTypeByXpath(startTimeId, inputTime);
99 String amPmSelectLocator = "//*[@id='" + idPrefix + "StartTimeAmPm" + addLineIdSuffix + "']";
100
101 selectByXpath(amPmSelectLocator, "PM");
102 assertEquals("PM", getAttributeByXpath(amPmSelectLocator, "value"));
103 Thread.sleep(5000);
104 waitAndClickByXpath("//button");
105 Thread.sleep(5000);
106
107 assertTrue("line (//input[@value='7:06'])is not present https://jira.kuali.org/browse/KULRICE-8162 Configuration Test View Time Info add line button doesn't addline", isElementPresentByXpath("//input[@value='7:06']"));
108 passed();
109 }
110
111
112
113
114
115 @Test
116 public void testAddLineWithAllDay() throws Exception {
117 openConfigurationTestView();
118
119 selectFrame("iframeportlet");
120
121 confirmAddLineControlsPresent();
122
123 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']";
124
125 String inputTime = "5:20";
126 waitAndTypeByXpath(startTimeId, inputTime);
127
128 String allDaySelector = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']";
129
130 Thread.sleep(5000);
131 waitAndClickByXpath(allDaySelector);
132
133 Thread.sleep(5000);
134 waitAndClick("div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button");
135 Thread.sleep(5000);
136 passed();
137 }
138
139
140
141
142 private void confirmAddLineControlsPresent() {
143 String[] addLineIds = {"StartTime", "StartTimeAmPm", "AllDay"};
144
145 for (String id: addLineIds) {
146 String tagId = "//*[@id='" + idPrefix + id + addLineIdSuffix + "']";
147 assertTrue("Did not find id " + tagId, isElementPresentByXpath(tagId));
148 }
149 }
150
151
152
153
154
155 @Test
156 public void testAddLineAllDay() throws Exception{
157 openConfigurationTestView();
158
159 selectFrame("iframeportlet");
160
161 confirmAddLineControlsPresent();
162
163
164 String cssCountRows = "div#ConfigurationTestView-ProgressiveRender-TimeInfoSection.uif-group div#ConfigurationTestView-ProgressiveRender-TimeInfoSection_disclosureContent.uif-disclosureContent table tbody tr";
165 int rowCount = (getCssCount(cssCountRows));
166
167 String allDayId = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']";
168 Thread.sleep(5000);
169 waitAndClickByXpath(allDayId);
170 waitAndClick("div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button");
171 Thread.sleep(5000);
172
173
174 assertEquals("line was not added", rowCount + 1, (getCssCount(cssCountRows)));
175 passed();
176 }
177 }