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 navigateToLibraryDemo("Widgets", "Suggest");
40 }
41
42 protected void testWidgetsSuggest(String exampleLink, String inputFieldName, String search,
43 String result) throws Exception {
44
45
46 waitAndClickByLinkText(exampleLink);
47
48
49 waitAndTypeByName(inputFieldName, search);
50
51
52 waitForElementPresent(By.linkText(result), "Library Widget Suggest, CAT not suggested");
53 assertElementPresentByLinkText(result);
54 waitAndClickByLinkText(result);
55
56
57 if (!driver.findElement(By.name(inputFieldName)).getAttribute("value").equals(result)) {
58 fail("input text is incorrect");
59 }
60
61 }
62
63 protected void testWidgetsSuggestHelperMethod2() throws Exception {
64
65 final String EXAMPLE_LINK_NAME = "View Helper Method Configuration 2";
66 final String INPUT_FIELD_NAME = "inputField4";
67 final String SEARCH_VALUE = "a";
68 final String RESULT = "a6";
69
70
71 waitAndClickByLinkText(EXAMPLE_LINK_NAME);
72
73
74 waitAndTypeByName("inputField3", "a6-sub");
75 waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
76
77
78 assertElementPresentByLinkText(RESULT);
79 waitAndClickByLinkText(RESULT);
80
81
82 if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals(RESULT)) {
83 fail("input text is incorrect");
84 }
85 }
86
87 protected void testWidgetsSuggestRichText() throws Exception {
88
89 final String EXAMPLE_LINK_NAME = "Rich suggest options";
90 final String INPUT_FIELD_NAME = "inputField8";
91 final String SEARCH_VALUE = "r";
92
93
94 waitAndClickByLinkText(EXAMPLE_LINK_NAME);
95
96
97 waitAndTypeByName(INPUT_FIELD_NAME, SEARCH_VALUE);
98
99
100 WebElement resultLink = driver.findElement(By.partialLinkText("Rich Option 1"));
101 resultLink.click();
102
103
104 if (!driver.findElement(By.name(INPUT_FIELD_NAME)).getAttribute("value").equals("r1")) {
105 fail("input text is incorrect");
106 }
107 }
108
109 @Test
110 public void testWidgetsTooltipBookmark() throws Exception {
111 testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
112 testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
113 testWidgetsSuggestHelperMethod2();
114 testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "sub", "sub-a3");
115 testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
116 testWidgetsSuggestRichText();
117 testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
118 testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
119 driver.close();
120 passed();
121 }
122
123 @Test
124 public void testWidgetsTooltipNav() throws Exception {
125 testWidgetsSuggest("Auto-Query Configuration", "inputField1", "ca", "CAT");
126 testWidgetsSuggest("View Helper Method Configuration 1", "inputField2", "a1", "a14");
127 testWidgetsSuggestHelperMethod2();
128 testWidgetsSuggest("Service Method and Sorting Configuration", "inputField6", "sub", "sub-a3");
129 testWidgetsSuggest("Local suggest options", "inputField7", "cold", "ColdFusion");
130 testWidgetsSuggestRichText();
131 testWidgetsSuggest("Configured suggest options", "inputField9", "cold", "ColdFusion");
132 testWidgetsSuggest("Custom selection", "inputField10", "jm", "jmcross");
133 driver.close();
134 passed();
135 }
136 }
137
138