1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.library.containers;
17
18 import org.junit.Ignore;
19 import org.junit.Test;
20
21 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
22 import org.openqa.selenium.By;
23 import org.openqa.selenium.NoSuchElementException;
24 import org.openqa.selenium.WebElement;
25
26
27
28
29 public class LibraryContainerDialogGroupAft extends WebDriverLegacyITBase {
30
31
32
33
34 public static final String BOOKMARK_URL = "/kr-krad/dialog?viewId=Demo-DialogGroupView";
35
36 @Override
37 protected String getBookmarkUrl() {
38 return BOOKMARK_URL;
39 }
40
41 @Override
42 protected void navigate() throws Exception {
43 waitAndClickLibraryLink();
44 waitAndClickByLinkText("Containers");
45 waitAndClickByLinkText("Dialog Group");
46 }
47
48 protected void testContainerDialogGroupConfirmAction() throws Exception {
49 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example1']/button");
50 waitAndClickByXpath("//section[@id='Uif-DialogGroup-YesNotmp']/div/div/div[@data-parent='Uif-DialogGroup-YesNo']/button[contains(text(),'No')]");
51 }
52
53 protected void testContainerDialogGroupConfirmWithExplaination() throws Exception {
54 waitAndClickByLinkText("Confirm with Explanation");
55 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example2']/button");
56 waitForElementPresentByXpath("//section[@id='Demo-DialogEx2']/div/div/div[@class='modal-body']/div/div/textarea");
57 waitAndClickByXpath("//section[@id='Demo-DialogEx2']/div/div/div[@data-parent='Demo-DialogEx2']/button[contains(text(),'OK')]");
58 waitForElementPresentByXpath("//a[contains(text(),'Required')]");
59 waitAndClickByXpath("//section[@id='Demo-DialogEx2']/div/div/div[@data-parent='Demo-DialogEx2']/button[contains(text(),'Cancel')]");
60 }
61
62 protected void testContainerDialogGroupGetDialogResponse1() throws Exception {
63 waitAndClickByLinkText("Get Dialog Response Ex. 1");
64 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example3']/button");
65 waitAndClickByXpath("//section[@id='Demo-DialogGroup-DialogResponse1']/div/div/div[@data-parent='Demo-DialogGroup-DialogResponse1']/button[contains(text(),'OK')]");
66 acceptAlertIfPresent();
67 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example3']/button");
68 waitAndClickByXpath("//section[@id='Demo-DialogGroup-DialogResponse1']/div/div/div[@data-parent='Demo-DialogGroup-DialogResponse1']/button[contains(text(),'Cancel')]");
69 acceptAlertIfPresent();
70 }
71
72 protected void testContainerDialogGroupGetDialogResponse2() throws Exception {
73 waitAndClickByLinkText("Get Dialog Response Ex. 2");
74 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example4']/button");
75 waitAndClickByXpath("//section[@id='Demo-DialogGroup-DialogResponse2']/div/div/div[@data-parent='Demo-DialogGroup-DialogResponse2']/button[contains(text(),'Green Eggs and Ham')]");
76 acceptAlertIfPresent();
77 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example4']/button");
78 waitAndClickByXpath("//section[@id='Demo-DialogGroup-DialogResponse2']/div/div/div[@data-parent='Demo-DialogGroup-DialogResponse2']/button[contains(text(),'Cat in the Hat')]");
79 acceptAlertIfPresent();
80 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example4']/button");
81 waitAndClickByXpath("//section[@id='Demo-DialogGroup-DialogResponse2']/div/div/div[@data-parent='Demo-DialogGroup-DialogResponse2']/button[contains(text(),'The Grinch')]");
82 acceptAlertIfPresent();
83 }
84
85 protected void testContainerDialogGroupShowDialog1() throws Exception {
86 waitAndClickByLinkText("Show Dialog Ex. 1");
87 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example5']/a[contains(text(),'Show Dialog')]");
88 waitForElementPresentByXpath("//input[@name='inputField1']");
89 waitForElementPresentByXpath("//input[@name='inputField2']");
90 waitForElementPresentByXpath("//input[@name='inputField3']");
91 waitForElementPresentByXpath("//input[@name='inputField4']");
92 waitForElementPresentByXpath("//input[@name='inputField5']");
93 waitAndClickByXpath("//section[@id='Demo-DialogGroup-ShowDialog1']/div/div/div[@data-parent='Demo-DialogGroup-ShowDialog1']/button[contains(text(),'Continue')]");
94 }
95
96 protected void testContainerDialogGroupShowDialog2() throws Exception {
97 waitAndClickByLinkText("Show Dialog Ex. 2");
98 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example6']/a[contains(text(),'Show Dialog')]");
99 waitForElementPresentByXpath("//section[@id='Demo-DialogGroup-ShowDialog2Refresh' and @style='display: none; background-color: rgba(255, 248, 198, 0);']");
100 waitAndClickByXpath("//input[@name='inputField6' and @value='show']");
101 waitForElementPresentByXpath("//section[@id='Demo-DialogGroup-ShowDialog2Refresh' and @style='display: block; background-color: rgba(255, 248, 198, 0);']");
102 waitAndClickByXpath("//section[@id='Demo-DialogGroup-ShowDialog2']/div/div/div[@data-parent='Demo-DialogGroup-ShowDialog2']/button[contains(text(),'OK')]");
103 }
104
105 protected void testContainerDialogGroupDialogEvents() throws Exception {
106 waitAndClickByLinkText("Dialog Events");
107 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example7']/button");
108 waitAndClickByXpath("//section[@id='Demo-DialogGroup-DialogEvents']/div/div/div[@data-parent='Demo-DialogGroup-DialogEvents']/button[contains(text(),'Continue')]");
109 acceptAlertIfPresent();
110 acceptAlertIfPresent();
111 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example7']/button");
112 waitAndClickByXpath("//section[@id='Demo-DialogGroup-DialogEvents']/div/div/div[@data-parent='Demo-DialogGroup-DialogEvents']/button[contains(text(),'Log out')]");
113 acceptAlertIfPresent();
114 acceptAlertIfPresent();
115 }
116
117 protected void testContainerDialogGroupServerDialog1() throws Exception {
118 waitAndClickByLinkText("Server Dialog Ex. 1");
119 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example8']/button");
120 waitForProgressLoading();
121 waitAndClickByXpath(
122 "//section[@id='Demo-DialogGroup-ServerResponse1']/div/div/div[@data-parent='Demo-DialogGroup-ServerResponse1']/button[contains(text(),'Yes')]");
123 waitForElementPresentByXpath("//div[@id='Demo-DialogGroup-Example8_messages']/ul/li[contains(text(), 'Save was completed.')]");
124 }
125
126 protected void testContainerDialogGroupServerDialog2() throws Exception {
127 waitAndClickByLinkText("Server Dialog Ex. 2");
128 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example9']/button");
129 waitForProgressLoading();
130 waitAndClickByXpath("//section[@id='Demo-DialogGroup-ServerResponse2']/div/div/div[@data-parent='Demo-DialogGroup-ServerResponse2']/button[contains(text(),'OK')]");
131 waitForElementPresentByXpath("//a[contains(text(),'Required')]");
132 waitIsVisible(By.xpath("//section[@id='Demo-DialogGroup-ServerResponse2']/div/div/div[@data-parent='Demo-DialogGroup-ServerResponse2']/button[contains(text(),'Cancel')]"));
133 waitAndClickByXpath("//section[@id='Demo-DialogGroup-ServerResponse2']/div/div/div[@data-parent='Demo-DialogGroup-ServerResponse2']/button[contains(text(),'Cancel')]");
134 }
135
136 protected void testContainerDialogGroupAjaxRetrieval() throws Exception {
137 waitAndClickByLinkText("Ajax Retrieval");
138
139 }
140
141 protected void testContainerDialogGroupValidationInDialog() throws Exception {
142 waitAndClickByLinkText("Validation in Dialog");
143 waitAndClickByLinkText("Show Dialog");
144 waitAndClickByXpath("//section[@id='Demo-DialogGroup-ShowDialog11']/div/div/div[@data-parent='Demo-DialogGroup-ShowDialog11']/button[contains(text(),'Continue')]");
145 waitForElementPresentByXpath("//a[contains(text(),'Field 1: Required')]");
146 waitForElementPresentByXpath("//a[contains(text(),'Field 2: Required')]");
147 waitForElementPresentByXpath("//a[contains(text(),'Field 3: Required')]");
148 waitForElementPresentByXpath("//a[contains(text(),'Field 4: Required')]");
149 waitForElementPresentByXpath("//a[contains(text(),'Field 5: Required')]");
150 waitAndClickByXpath("//section[@id='Demo-DialogGroup-ShowDialog11']/div/div/header/button");
151 }
152
153 protected void testContainerDialogGroupDialogReuse() throws Exception {
154 Thread.sleep(1000);
155 waitAndClickByLinkText("Dialog Reuse");
156
157
158 assertEquals("1", waitForElementVisibleBy(By.name("collection2[1].field1")).getAttribute("value"));
159 assertEquals("2", waitForElementVisibleBy(By.name("collection2[1].field2")).getAttribute("value"));
160 assertEquals("3", waitForElementVisibleBy(By.name("collection2[1].field3")).getAttribute("value"));
161
162 jGrowl("Click Delete");
163
164 waitAndClickByXpath("//button[@id='Demo-DialogGroup-WizardStep2_del_line1']");
165 jGrowl("Cancel Delete");
166 waitForTextPresent("Are you sure you wish to delete line: 1?");
167 waitAndClickByXpath("//section[@id='Uif-DialogGroup-YesNotmp']/div/div/div[@data-parent='Uif-DialogGroup-YesNo']/button[contains(text(),'No')]");
168
169
170 assertEquals("1", waitForElementVisibleBy(By.name("collection2[1].field1")).getAttribute("value"));
171 assertEquals("2", waitForElementVisibleBy(By.name("collection2[1].field2")).getAttribute("value"));
172 assertEquals("3", waitForElementVisibleBy(By.name("collection2[1].field3")).getAttribute("value"));
173
174 jGrowl("Click Delete");
175 waitAndClickByXpath("//button[@id='Demo-DialogGroup-WizardStep2_del_line0']");
176 waitForTextPresent("Are you sure you wish to delete line: A?");
177 jGrowl("Confirm Delete");
178 waitAndClickByXpath("//section[@id='Uif-DialogGroup-YesNotmp']/div/div/div[@data-parent='Uif-DialogGroup-YesNo']/button[contains(text(),'Yes')]");
179 waitForProgressDeletingLine();
180
181
182 assertEquals("a", waitForElementVisibleBy(By.name("collection2[2].field1")).getAttribute("value"));
183 assertEquals("b", waitForElementVisibleBy(By.name("collection2[2].field2")).getAttribute("value"));
184 assertEquals("c", waitForElementVisibleBy(By.name("collection2[2].field3")).getAttribute("value"));
185 }
186
187 protected void testContainerDialogGroupSmallDialog() throws Exception {
188 waitAndClickByLinkText("Small Dialog");
189 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example13']/a");
190 waitAndClickByXpath("//section[@id='Demo-DialogGroup-ShowSmallDialog']/div/div/div[@data-parent='Demo-DialogGroup-ShowSmallDialog']/button[contains(text(),'OK')]");
191 }
192
193 protected void testContainerDialogGroupLargeDialog() throws Exception {
194 waitAndClickByLinkText("Large Dialog");
195 waitAndClickByXpath("//section[@id='Demo-DialogGroup-Example14']/a");
196 waitAndClickByXpath("//section[@id='Demo-DialogGroup-ShowLargeDialog']/div/div/div[@data-parent='Demo-DialogGroup-ShowLargeDialog']/button[contains(text(),'OK')]");
197 }
198
199 protected void testContainerDialogGroupDestroyDialogOnHidden() throws Exception {
200 WebElement exampleAnchorElement = findElement(By.cssSelector("a[id^='Demo-DialogGroup-Example15']"));
201 exampleAnchorElement.click();
202 WebElement dialog = findElement(By.cssSelector(
203 "section[id='Demo-DialogGroup-DestroyDialogOnHidden'] > div.modal-dialog"));
204 assertTrue("Dialog should not be visisble on page load.", !dialog.isDisplayed());
205 WebElement dialogLink = findElement(By.cssSelector("section[id='Demo-DialogGroup-Example15'] > a"));
206 dialogLink.click();
207 waitForProgressLoading();
208 dialog = waitForElementVisibleBy(By.cssSelector("section[id='Demo-DialogGroup-DestroyDialogOnHidden']"));
209 WebElement anyButton = dialog.findElement(By.cssSelector("button:first-of-type"));
210 anyButton.click();
211 try {
212 dialog = waitAndGetElementByAttributeValue("id", "Demo-DialogGroup-DestroyDialogOnHidden");
213 assertFalse("Dialog should not be present.", dialog.isDisplayed());
214 } catch (NoSuchElementException exception) {
215 }
216 }
217
218 protected void testContainerDialogGroupAll() throws Exception {
219 testContainerDialogGroupConfirmAction();
220 testContainerDialogGroupGetDialogResponse1();
221 testContainerDialogGroupGetDialogResponse2();
222 testContainerDialogGroupShowDialog1();
223 testContainerDialogGroupShowDialog2();
224 testContainerDialogGroupServerDialog1();
225
226 testContainerDialogGroupAjaxRetrieval();
227
228 testContainerDialogGroupDialogReuse();
229
230
231
232 testContainerDialogGroupDialogEvents();
233 }
234
235 @Test
236 public void testContainerDialogGroupBookmark() throws Exception {
237 testContainerDialogGroupAll();
238 passed();
239 }
240
241 @Test
242 public void testContainerDialogGroupNav() throws Exception {
243 testContainerDialogGroupAll();
244 passed();
245 }
246
247 @Test
248 public void testContainerDialogGroupLargeDialogBookmark() throws Exception {
249 testContainerDialogGroupLargeDialog();
250 passed();
251 }
252
253 @Test
254 public void testContainerDialogGroupLargeDialogNav() throws Exception {
255 testContainerDialogGroupLargeDialog();
256 passed();
257 }
258
259 @Test
260 public void testContainerDialogGroupServerDialog2Bookmark() throws Exception {
261 testContainerDialogGroupServerDialog2();
262 passed();
263 }
264
265 @Test
266 public void testContainerDialogGroupServerDialog2Nav() throws Exception {
267 testContainerDialogGroupServerDialog2();
268 passed();
269 }
270
271 @Test
272 public void testContainerDialogGroupValidationInDialogBookmark() throws Exception {
273 testContainerDialogGroupValidationInDialog();
274 passed();
275 }
276
277 @Test
278 public void testContainerDialogGroupValidationInDialogNav() throws Exception {
279 testContainerDialogGroupValidationInDialog();
280 passed();
281 }
282
283 @Test
284 public void testContainerDialogGroupSmallDialogBookmark() throws Exception {
285 testContainerDialogGroupSmallDialog();
286 passed();
287 }
288
289 @Test
290 public void testContainerDialogGroupSmallDialogNav() throws Exception {
291 testContainerDialogGroupSmallDialog();
292 passed();
293 }
294
295 @Test
296 public void testContainerDialogGroupDestroyDialogOnHiddenBookmark() throws Exception {
297 testContainerDialogGroupDestroyDialogOnHidden();
298 passed();
299 }
300
301 @Test
302 public void testContainerDialogGroupDestroyDialogOnHiddenNav() throws Exception {
303 testContainerDialogGroupDestroyDialogOnHidden();
304 passed();
305 }
306 }