1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.library.widgets;
17
18 import org.junit.Test;
19 import org.kuali.rice.krad.demo.uif.library.LibraryBase;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.WebElement;
22
23
24
25
26 public class LibraryWidgetsDisclosureAft extends LibraryBase {
27
28
29
30
31 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-DisclosureView&methodToCall=start";
32
33 @Override
34 protected String getBookmarkUrl() {
35 return BOOKMARK_URL;
36 }
37
38 @Override
39 protected void navigate() throws Exception {
40 navigateToLibraryDemo("Widgets", "Disclosure");
41 }
42
43 protected void testWidgetsDisclosureDefault() throws Exception {
44 waitAndClickByLinkText("Default");
45 if (!isElementPresentByXpath("//a/span[contains(text(),'Disclosure Section')]") && !isElementPresentByXpath("//a/span[contains(text(),'Predefined Disclosure Section')]")) {
46 fail("First disclosure not displayed");
47 }
48
49 waitAndClickByLinkText("Disclosure Section");
50 Thread.sleep(1000);
51 waitAndClickByLinkText("Predefined Disclosure Section");
52 Thread.sleep(1000);
53
54 if (isElementPresentByXpath("//div[@id='Demo-Disclosure-Example1']/div[@class='uif-verticalBoxLayout clearfix']/div/div[@data-open='true']")) {
55 fail("First disclosure did not close");
56 }
57 }
58
59 protected void testWidgetsDisclosureClosed() throws Exception {
60 waitAndClickByLinkText("Closed");
61 WebElement exampleDiv = navigateToExample("Demo-Disclosure-Example2");
62 WebElement disclosure = findElement(By.cssSelector(".uif-disclosureContent"), exampleDiv);
63
64 if (disclosure.isDisplayed()) {
65 fail("Disclosure did not default closed");
66 }
67
68 waitAndClickByLinkText("Default Closed Section");
69 Thread.sleep(1000);
70
71 if (!disclosure.isDisplayed()) {
72 fail("Disclosure did not open");
73 }
74 }
75
76 protected void testWidgetsDisclosureAnimationSpeed() throws Exception {
77 waitAndClickByLinkText("Animation Speed");
78 assertElementPresentByName("inputField7");
79 assertElementPresentByName("inputField10");
80 waitAndClickByXpath("//section[@data-parent='Demo-Disclosure-Example3']/header/h3/a/span");
81 waitForElementPresentByXpath("//section[@data-parent='Demo-Disclosure-Example3']/header[@style='display: none;']");
82 }
83
84 protected void testWidgetsDisclosureRenderImage() throws Exception {
85 waitAndClickByLinkText("Render Image");
86 assertElementPresentByName("inputField11");
87 assertElementPresentByName("inputField12");
88 waitAndClickByXpath("//section[@data-parent='Demo-Disclosure-Example4']/header/h3/a/span");
89 waitForElementPresentByXpath("//section[@data-parent='Demo-Disclosure-Example4']/header[@style='display: none;']");
90 }
91
92 protected void testWidgetsDisclosureChangeImage() throws Exception {
93 waitAndClickByLinkText("Change Image");
94 waitForElementPresentByXpath("//span[@class='icon-folder-open']");
95 waitAndClickByXpath("//section[@data-parent='Demo-Disclosure-Example5']/header/h3/a/span");
96
97 waitForElementPresentByXpath("//span[@class='icon-folder']");
98 }
99
100 protected void testWidgetsDisclosureAjaxRetrieval() throws Exception {
101 waitAndClickByLinkText("Ajax Retrieval");
102 waitAndClickByLinkText("Disclosure Section (ajax retrieval)");
103 waitForTextPresent("Loading..");
104 waitForTextPresent("Field 1");
105 waitForTextPresent("Field 2");
106 }
107
108 @Test
109 public void testWidgetsDisclosureBookmark() throws Exception {
110 testWidgetsDisclosureDefault();
111 testWidgetsDisclosureClosed();
112 testWidgetsDisclosureAnimationSpeed();
113 testWidgetsDisclosureRenderImage();
114 testWidgetsDisclosureChangeImage();
115 testWidgetsDisclosureAjaxRetrieval();
116 passed();
117 }
118
119 @Test
120 public void testWidgetsDisclosureNav() throws Exception {
121 testWidgetsDisclosureDefault();
122 testWidgetsDisclosureClosed();
123 testWidgetsDisclosureAnimationSpeed();
124 testWidgetsDisclosureRenderImage();
125 testWidgetsDisclosureChangeImage();
126 testWidgetsDisclosureAjaxRetrieval();
127 passed();
128 }
129 }