1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.krad.demo.uif.library;
17
18 import org.junit.Test;
19 import org.openqa.selenium.By;
20 import org.openqa.selenium.WebElement;
21
22
23
24
25 public class DemoLibraryWidgetsSuggestSmokeTest extends DemoLibraryBase {
26
27
28
29
30 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Suggest-View&methodToCall=start";
31
32 @Override
33 protected String getBookmarkUrl() {
34 return BOOKMARK_URL;
35 }
36
37 @Override
38 protected void navigate() throws Exception {
39 waitAndClickById("Demo-LibraryLink", "");
40 waitAndClickByLinkText("Widgets");
41 waitAndClickByLinkText("Suggest");
42 }
43
44 protected void testWidgetsSuggest(String exampleLink, String inputFieldName, String search,
45 String result) throws Exception {
46
47
48 waitAndClickByLinkText(exampleLink);
49
50
51 waitAndTypeByName(inputFieldName, search);
52
53
54 waitForElementPresent(By.linkText(result), "Library Widget Suggest, CAT not suggested");
55 assertElementPresentByLinkText(result);
56 waitAndClickByLinkText(result);
57
58
59 if (!driver.findElement(By.name(inputFieldName)).getAttribute("value").equals(result)) {
60 fail("input text is incorrect");
61 }
62
63 }
64
65 protected void testWidgetsSuggestHelperMethod2() throws Exception {
66
67 final String EXAMPLE_LINK_NAME = "View Helper Method Configuration 2";
68 final String INPUT_FIELD_NAME = "inputField4";
69 final String SEARCH_VALUE = "a";
70 final String RESULT = "a6";
71
72
73 waitAndClickByLinkText(EXAMPLE_LINK_NAME);
74
75
76 waitAndTypeByName("inputField3", "a6-sub");
77 waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
78
79
80 assertElementPresentByLinkText(RESULT);
81 waitAndClickByLinkText(RESULT);
82
83
84 if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals(RESULT)) {
85 fail("input text is incorrect");
86 }
87 }
88
89 protected void testWidgetsSuggestRichText() throws Exception {
90
91 final String EXAMPLE_LINK_NAME = "Rich suggest options";
92 final String INPUT_FIELD_NAME = "inputField8";
93 final String SEARCH_VALUE = "r";
94
95
96 waitAndClickByLinkText(EXAMPLE_LINK_NAME);
97
98
99 waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
100
101
102 WebElement resultLink = driver.findElement(By.partialLinkText("Rich Option 1"));
103 resultLink.click();
104
105
106 if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals("r1")) {
107 fail("input text is incorrect");
108 }
109 }
110
111 @Test
112 public void testWidgetsTooltipBookmark() throws Exception {
113 testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
114 testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
115 testWidgetsSuggestHelperMethod2();
116 testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "sub", "sub-a3");
117 testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
118 testWidgetsSuggestRichText();
119 testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
120 testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
121 driver.close();
122 passed();
123 }
124
125 @Test
126 public void testWidgetsTooltipNav() throws Exception {
127 testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
128 testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
129 testWidgetsSuggestHelperMethod2();
130 testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "sub", "sub-a3");
131 testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
132 testWidgetsSuggestRichText();
133 testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
134 testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
135 driver.close();
136 passed();
137 }
138 }
139
140