1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.krad.library.elements;
17
18 import static org.junit.Assert.assertTrue;
19
20 import org.junit.Test;
21 import org.openqa.selenium.By;
22
23 import com.thoughtworks.selenium.SeleneseTestBase;
24
25 import org.kuali.rice.testtools.selenium.Failable;
26 import org.kuali.rice.testtools.selenium.ITUtil;
27 import org.kuali.rice.testtools.selenium.SmokeTestBase;
28 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
29
30
31
32
33 public class DemoLibraryElementsActionSmokeTest extends SmokeTestBase {
34
35
36
37
38 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Action-View&methodToCall=start";
39
40 @Override
41 protected String getBookmarkUrl() {
42 return BOOKMARK_URL;
43 }
44
45 @Override
46 protected void navigate() throws Exception {
47 waitAndClickById("Demo-LibraryLink", "");
48 waitAndClickByLinkText("Elements");
49 waitAndClickByLinkText("Action");
50 }
51
52 protected void testActionDefault() throws Exception {
53 waitForElementPresentByClassName("uif-headerText-span");
54 assertTextPresent("Default");
55 SeleneseTestBase.assertTrue(getTextByClassName("uif-instructionalMessage").contains(
56 "Action with action script"));
57 assertElementPresentByLinkText("Action Link");
58 }
59
60 protected void testActionPresubmit() throws Exception {
61 waitAndClickByLinkText("Presubmit");
62 waitForElementPresentByClassName("uif-headerText-span");
63 assertTextPresent("Presubmit");
64 assertTextPresent("ActionLinkField with presubmit script");
65 assertElementPresentByLinkText("Pre submit returning true Link");
66 assertElementPresentByLinkText("Pre submit returning false Link");
67
68 waitAndClickByLinkText("Pre submit returning true Link");
69 assertTrue(driver.switchTo().alert().getText().contains("Pre submit call was invoked, returning true"));
70 driver.switchTo().alert().accept();
71
72 waitAndClickByLinkText("Pre submit returning false Link");
73 assertTrue(driver.switchTo().alert().getText().contains("Pre submit call was invoked, returning false"));
74 driver.switchTo().alert().accept();
75 }
76
77 protected void testActionSuccessCallback() throws Exception {
78 waitAndClickByLinkText("Success Callback");
79 waitForElementPresentByClassName("uif-headerText-span");
80 assertTextPresent("Action Field with a success callback script");
81 assertElementPresentByLinkText("Action Link success callback");
82
83 waitAndClickByLinkText("Action Link success callback");
84 assertTrue(driver.switchTo().alert().getText().contains("Refresh called successfully"));
85 driver.switchTo().alert().accept();
86 }
87
88 protected void testActionValidation() throws Exception {
89 waitForElementPresentByClassName("uif-page");
90 driver.findElement(By.className("uif-page")).findElement(By.linkText("Validation")).click();
91
92 waitForElementPresentByClassName("uif-headerText-span");
93 assertTextPresent("Action Field with client side validation");
94 assertTextPresent("InputField 1");
95 assertIsNotVisibleByXpath("//a[contains(text(),'Required')]");
96
97 waitAndClickByLinkText("Action Link with clientside validation");
98 assertIsVisibleByXpath("//a[contains(text(),'Required')]", "");
99
100 waitAndTypeByName("inputField1", "some text");
101 waitAndClickByLinkText("Action Link with clientside validation");
102 assertIsNotVisibleByXpath("//a[contains(text(),'Required')]");
103 }
104
105 protected void testActionImages() throws Exception {
106 waitAndClickByLinkText("Images");
107 waitForElementPresentByClassName("uif-headerText-span");
108 assertTextPresent("Images");
109 assertTextPresent("Action Field with images");
110
111 driver.findElement(By.partialLinkText("Action Link with left image")).findElement(By.className(
112 "leftActionImage"));
113 driver.findElement(By.partialLinkText("Action Link with right image")).findElement(By.className(
114 "rightActionImage"));
115 }
116
117 @Test
118 public void testLibraryElementsActionBookmark() throws Exception {
119 testActionDefault();
120 testActionPresubmit();
121 testActionSuccessCallback();
122 testActionValidation();
123 testActionImages();
124 passed();
125 }
126
127 @Test
128 public void testLibraryElementsActionNav() throws Exception {
129 testActionDefault();
130 testActionPresubmit();
131 testActionSuccessCallback();
132 testActionValidation();
133 testActionImages();
134 passed();
135 }
136 }