1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.wysiwyg.framework; |
21 |
|
|
22 |
|
import java.io.UnsupportedEncodingException; |
23 |
|
import java.net.URLEncoder; |
24 |
|
import java.util.Arrays; |
25 |
|
|
26 |
|
import org.openqa.selenium.By; |
27 |
|
import org.openqa.selenium.JavascriptExecutor; |
28 |
|
import org.openqa.selenium.Keys; |
29 |
|
import org.openqa.selenium.WebDriver; |
30 |
|
import org.openqa.selenium.WebElement; |
31 |
|
import org.openqa.selenium.support.ui.ExpectedCondition; |
32 |
|
import org.xwiki.test.selenium.framework.AbstractXWikiTestCase; |
33 |
|
|
34 |
|
import com.thoughtworks.selenium.Wait; |
35 |
|
|
36 |
|
import static org.junit.Assert.*; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@version |
42 |
|
|
|
|
| 91.6% |
Uncovered Elements: 29 (344) |
Complexity: 124 |
Complexity Density: 0.58 |
|
43 |
|
public class AbstractWysiwygTestCase extends AbstractXWikiTestCase |
44 |
|
{ |
45 |
|
private static final String WYSIWYG_LOCATOR_FOR_WYSIWYG_TAB = "//div[@role='tab'][@tabIndex=0]/div[.='WYSIWYG']"; |
46 |
|
|
47 |
|
private static final String WYSIWYG_LOCATOR_FOR_SOURCE_TAB = "//div[@role='tab'][@tabIndex=0]/div[.='Source']"; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
public static final String TOOLBAR_BUTTON_INDENT_TITLE = "Increase Indent"; |
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
public static final String TOOLBAR_BUTTON_OUTDENT_TITLE = "Decrease Indent"; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
public static final String TOOLBAR_BUTTON_UNDO_TITLE = "Undo (Ctrl+Z)"; |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
public static final String TOOLBAR_BUTTON_REDO_TITLE = "Redo (Ctrl+Y)"; |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
public static final String TOOLBAR_SELECT_STYLE = "//select[@title=\"Apply Style\"]"; |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
public static final String MENU_ITEM_BY_LABEL = |
78 |
|
"//td[contains(@class, 'gwt-MenuItem')]/div[@class = 'gwt-MenuItemLabel' and . = '%s']"; |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
public static final long SMALL_WAIT_INTERVAL = 50L; |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
85 |
283 |
@Override... |
86 |
|
public void setUp() |
87 |
|
{ |
88 |
283 |
super.setUp(); |
89 |
|
|
90 |
283 |
login(); |
91 |
283 |
open(this.getClass().getSimpleName(), getTestMethodName(), "edit", "editor=wysiwyg"); |
92 |
283 |
waitForEditorToLoad(); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
98 |
280 |
protected void login()... |
99 |
|
{ |
100 |
|
|
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
@return |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
106 |
968 |
protected RichTextAreaElement getRichTextArea()... |
107 |
|
{ |
108 |
968 |
WebDriver driver = getDriver(); |
109 |
968 |
return new RichTextAreaElement(driver, driver.findElement(By.className("gwt-RichTextArea"))); |
110 |
|
} |
111 |
|
|
112 |
|
|
113 |
|
@return |
114 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
1167 |
protected WebElement getSourceTextArea()... |
116 |
|
{ |
117 |
1167 |
return getDriver().findElement(By.className("xPlainTextEditor")); |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
@param |
124 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
20 |
public void setContent(String html)... |
126 |
|
{ |
127 |
20 |
getRichTextArea().setContent(html); |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
133 |
3 |
public void resetContent()... |
134 |
|
{ |
135 |
|
|
136 |
|
|
137 |
3 |
selectAllContent(); |
138 |
|
|
139 |
3 |
typeBackspace(); |
140 |
|
|
141 |
|
|
142 |
3 |
selectAllContent(); |
143 |
|
} |
144 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
145 |
34 |
public void selectAllContent()... |
146 |
|
{ |
147 |
34 |
getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "a")); |
148 |
|
} |
149 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
150 |
172 |
public void typeText(String text)... |
151 |
|
{ |
152 |
172 |
getRichTextArea().sendKeys(text); |
153 |
|
} |
154 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
155 |
19 |
public void typeTextThenEnter(String text)... |
156 |
|
{ |
157 |
19 |
getRichTextArea().sendKeys(text, Keys.RETURN); |
158 |
|
} |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
@param |
164 |
|
@param |
165 |
|
@param |
166 |
|
|
167 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
168 |
101 |
public void sendKey(Keys key, int count, boolean hold)... |
169 |
|
{ |
170 |
101 |
Keys[] sequence = new Keys[count]; |
171 |
101 |
Arrays.fill(sequence, key); |
172 |
101 |
if (hold) { |
173 |
2 |
getRichTextArea().sendKeys(Keys.chord(sequence)); |
174 |
|
} else { |
175 |
99 |
getRichTextArea().sendKeys(sequence); |
176 |
|
} |
177 |
|
} |
178 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
179 |
34 |
public void typeEnter()... |
180 |
|
{ |
181 |
34 |
typeEnter(1); |
182 |
|
} |
183 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
184 |
38 |
public void typeEnter(int nb)... |
185 |
|
{ |
186 |
38 |
sendKey(Keys.RETURN, nb, false); |
187 |
|
} |
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
189 |
15 |
public void typeShiftEnter()... |
190 |
|
{ |
191 |
15 |
getRichTextArea().sendKeys(Keys.chord(Keys.SHIFT, Keys.RETURN)); |
192 |
|
} |
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
194 |
1 |
public void typeControlEnter()... |
195 |
|
{ |
196 |
1 |
getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, Keys.RETURN)); |
197 |
|
} |
198 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
199 |
0 |
public void typeMetaEnter()... |
200 |
|
{ |
201 |
0 |
getRichTextArea().sendKeys(Keys.chord(Keys.META, Keys.RETURN)); |
202 |
|
} |
203 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
204 |
27 |
public void typeBackspace()... |
205 |
|
{ |
206 |
27 |
typeBackspace(1); |
207 |
|
} |
208 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
209 |
33 |
public void typeBackspace(int count)... |
210 |
|
{ |
211 |
33 |
typeBackspace(count, false); |
212 |
|
} |
213 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
214 |
34 |
public void typeBackspace(int count, boolean hold)... |
215 |
|
{ |
216 |
34 |
sendKey(Keys.BACK_SPACE, count, hold); |
217 |
|
} |
218 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
219 |
0 |
public void typeLeftArrow()... |
220 |
|
{ |
221 |
0 |
getRichTextArea().sendKeys(Keys.ARROW_LEFT); |
222 |
|
} |
223 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
224 |
0 |
public void typeUpArrow()... |
225 |
|
{ |
226 |
0 |
getRichTextArea().sendKeys(Keys.ARROW_UP); |
227 |
|
} |
228 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
229 |
0 |
public void typeRightArrow()... |
230 |
|
{ |
231 |
0 |
getRichTextArea().sendKeys(Keys.ARROW_RIGHT); |
232 |
|
} |
233 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
234 |
0 |
public void typeDownArrow()... |
235 |
|
{ |
236 |
0 |
getRichTextArea().sendKeys(Keys.ARROW_DOWN); |
237 |
|
} |
238 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
239 |
19 |
public void typeDelete()... |
240 |
|
{ |
241 |
19 |
typeDelete(1); |
242 |
|
} |
243 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
244 |
20 |
public void typeDelete(int count)... |
245 |
|
{ |
246 |
20 |
typeDelete(count, false); |
247 |
|
} |
248 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
249 |
21 |
public void typeDelete(int count, boolean hold)... |
250 |
|
{ |
251 |
21 |
sendKey(Keys.DELETE, count, hold); |
252 |
|
} |
253 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
254 |
7 |
public void typeTab()... |
255 |
|
{ |
256 |
7 |
typeTab(1); |
257 |
|
} |
258 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
259 |
8 |
public void typeTab(int count)... |
260 |
|
{ |
261 |
8 |
sendKey(Keys.TAB, count, false); |
262 |
|
} |
263 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
264 |
10 |
public void typeShiftTab()... |
265 |
|
{ |
266 |
10 |
getRichTextArea().sendKeys(Keys.chord(Keys.SHIFT, Keys.TAB)); |
267 |
|
} |
268 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
269 |
1 |
public void typeShiftTab(int count)... |
270 |
|
{ |
271 |
5 |
for (int i = 0; i < count; i++) { |
272 |
4 |
typeShiftTab(); |
273 |
|
} |
274 |
|
} |
275 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
276 |
13 |
public void clickUnorderedListButton()... |
277 |
|
{ |
278 |
13 |
pushToolBarButton("Bullets On/Off"); |
279 |
|
} |
280 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
281 |
3 |
public void clickOrderedListButton()... |
282 |
|
{ |
283 |
3 |
pushToolBarButton("Numbering On/Off"); |
284 |
|
} |
285 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
286 |
8 |
public void clickIndentButton()... |
287 |
|
{ |
288 |
8 |
pushToolBarButton(TOOLBAR_BUTTON_INDENT_TITLE); |
289 |
|
} |
290 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
291 |
0 |
public boolean isIndentButtonEnabled()... |
292 |
|
{ |
293 |
0 |
return isPushButtonEnabled(TOOLBAR_BUTTON_INDENT_TITLE); |
294 |
|
} |
295 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
296 |
7 |
public void clickOutdentButton()... |
297 |
|
{ |
298 |
7 |
pushToolBarButton(TOOLBAR_BUTTON_OUTDENT_TITLE); |
299 |
|
} |
300 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
301 |
0 |
public boolean isOutdentButtonEnabled()... |
302 |
|
{ |
303 |
0 |
return isPushButtonEnabled(TOOLBAR_BUTTON_OUTDENT_TITLE); |
304 |
|
} |
305 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
306 |
10 |
public void clickBoldButton()... |
307 |
|
{ |
308 |
10 |
pushToolBarButton("Bold (Ctrl+B)"); |
309 |
|
} |
310 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
311 |
2 |
public void clickItalicsButton()... |
312 |
|
{ |
313 |
2 |
pushToolBarButton("Italic (Ctrl+I)"); |
314 |
|
} |
315 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
316 |
2 |
public void clickUnderlineButton()... |
317 |
|
{ |
318 |
2 |
pushToolBarButton("Underline (Ctrl+U)"); |
319 |
|
} |
320 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
321 |
1 |
public void clickStrikethroughButton()... |
322 |
|
{ |
323 |
1 |
pushToolBarButton("Strikethrough"); |
324 |
|
} |
325 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
326 |
6 |
public void clickHRButton()... |
327 |
|
{ |
328 |
6 |
pushToolBarButton("Insert Horizontal Ruler"); |
329 |
|
} |
330 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
331 |
1 |
public void clickSubscriptButton()... |
332 |
|
{ |
333 |
1 |
pushToolBarButton("Subscript"); |
334 |
|
} |
335 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
336 |
1 |
public void clickSuperscriptButton()... |
337 |
|
{ |
338 |
1 |
pushToolBarButton("Superscript"); |
339 |
|
} |
340 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
341 |
15 |
public void clickUndoButton()... |
342 |
|
{ |
343 |
15 |
pushToolBarButton(TOOLBAR_BUTTON_UNDO_TITLE); |
344 |
|
} |
345 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
346 |
5 |
public void clickUndoButton(int count)... |
347 |
|
{ |
348 |
18 |
for (int i = 0; i < count; i++) { |
349 |
13 |
clickUndoButton(); |
350 |
|
} |
351 |
|
} |
352 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
353 |
9 |
public void clickRedoButton()... |
354 |
|
{ |
355 |
9 |
pushToolBarButton(TOOLBAR_BUTTON_REDO_TITLE); |
356 |
|
} |
357 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
358 |
1 |
public void clickRedoButton(int count)... |
359 |
|
{ |
360 |
8 |
for (int i = 0; i < count; i++) { |
361 |
7 |
clickRedoButton(); |
362 |
|
} |
363 |
|
} |
364 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
365 |
7 |
public void clickSymbolButton()... |
366 |
|
{ |
367 |
7 |
pushToolBarButton("Insert Custom Character"); |
368 |
|
} |
369 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
370 |
0 |
public void clickOfficeImporterButton()... |
371 |
|
{ |
372 |
0 |
pushToolBarButton("Import Office Content"); |
373 |
|
} |
374 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
375 |
2 |
public void clickBackToEdit()... |
376 |
|
{ |
377 |
2 |
submit("//input[@type = 'submit' and @value = 'Back To Edit']"); |
378 |
2 |
waitForEditorToLoad(); |
379 |
|
} |
380 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
381 |
45 |
public void applyStyle(final String style)... |
382 |
|
{ |
383 |
|
|
384 |
45 |
new Wait() |
385 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
386 |
45 |
public boolean until()... |
387 |
|
{ |
388 |
45 |
return getSelenium().isEditable(TOOLBAR_SELECT_STYLE) |
389 |
|
&& (!getSelenium().isSomethingSelected(TOOLBAR_SELECT_STYLE) || !style.equals(getSelenium() |
390 |
|
.getSelectedLabel(TOOLBAR_SELECT_STYLE))); |
391 |
|
} |
392 |
|
}.wait("The specified style, '" + style + "', is already applied!"); |
393 |
45 |
getSelenium().select(TOOLBAR_SELECT_STYLE, style); |
394 |
|
} |
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
@param |
400 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
401 |
2 |
public void waitForStyleDetected(final String style)... |
402 |
|
{ |
403 |
2 |
new Wait() |
404 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
405 |
3 |
public boolean until()... |
406 |
|
{ |
407 |
3 |
return getSelenium().isSomethingSelected(TOOLBAR_SELECT_STYLE) |
408 |
|
&& style.equals(getSelenium().getSelectedLabel(TOOLBAR_SELECT_STYLE)); |
409 |
|
} |
410 |
|
}.wait("The specified style, '" + style + "', wasn't detected!"); |
411 |
|
} |
412 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
413 |
7 |
public void applyStylePlainText()... |
414 |
|
{ |
415 |
7 |
applyStyle("Plain text"); |
416 |
|
} |
417 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
418 |
21 |
public void applyStyleTitle1()... |
419 |
|
{ |
420 |
21 |
applyStyle("Title 1"); |
421 |
|
} |
422 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
423 |
3 |
public void applyStyleTitle2()... |
424 |
|
{ |
425 |
3 |
applyStyle("Title 2"); |
426 |
|
} |
427 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
428 |
3 |
public void applyStyleTitle3()... |
429 |
|
{ |
430 |
3 |
applyStyle("Title 3"); |
431 |
|
} |
432 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
433 |
2 |
public void applyStyleTitle4()... |
434 |
|
{ |
435 |
2 |
applyStyle("Title 4"); |
436 |
|
} |
437 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
438 |
8 |
public void applyStyleTitle5()... |
439 |
|
{ |
440 |
8 |
applyStyle("Title 5"); |
441 |
|
} |
442 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
443 |
1 |
public void applyStyleTitle6()... |
444 |
|
{ |
445 |
1 |
applyStyle("Title 6"); |
446 |
|
} |
447 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
448 |
129 |
public void pushButton(String locator)... |
449 |
|
{ |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
454 |
|
|
455 |
129 |
getSelenium().mouseOver(locator); |
456 |
129 |
getSelenium().mouseDown(locator); |
457 |
129 |
getSelenium().mouseUp(locator); |
458 |
129 |
getSelenium().mouseOut(locator); |
459 |
|
} |
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
@param |
465 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
466 |
129 |
public void pushToolBarButton(String title)... |
467 |
|
{ |
468 |
129 |
pushButton("//div[@title='" + title + "']"); |
469 |
|
} |
470 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
471 |
187 |
public void clickButtonWithText(String buttonText)... |
472 |
|
{ |
473 |
187 |
getSelenium().click("//button[. = \"" + buttonText + "\"]"); |
474 |
|
} |
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
@param@link |
480 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
481 |
353 |
public void clickMenu(String menuLabel)... |
482 |
|
{ |
483 |
353 |
String selector = String.format(MENU_ITEM_BY_LABEL, menuLabel); |
484 |
|
|
485 |
353 |
getSelenium().mouseOver(selector); |
486 |
|
|
487 |
353 |
getSelenium().click(selector); |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
@param |
494 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
495 |
0 |
public void waitForMenu(String menuLabel)... |
496 |
|
{ |
497 |
0 |
waitForElement(String.format(MENU_ITEM_BY_LABEL, menuLabel)); |
498 |
|
} |
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
|
503 |
|
@param |
504 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
505 |
4 |
public void closeMenuContaining(String menuLabel)... |
506 |
|
{ |
507 |
4 |
getSelenium().typeKeys(String.format(MENU_ITEM_BY_LABEL, menuLabel), "\\27"); |
508 |
|
} |
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
514 |
188 |
public void switchToWysiwyg()... |
515 |
|
{ |
516 |
188 |
switchToWysiwyg(true); |
517 |
|
} |
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
@param |
523 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
524 |
194 |
public void switchToWysiwyg(boolean wait)... |
525 |
|
{ |
526 |
194 |
ensureElementIsNotCoveredByFloatingMenu(By.xpath(WYSIWYG_LOCATOR_FOR_WYSIWYG_TAB)); |
527 |
194 |
getSelenium().click(WYSIWYG_LOCATOR_FOR_WYSIWYG_TAB); |
528 |
194 |
if (wait) { |
529 |
188 |
final String enabledToolBarButtonXPath = |
530 |
|
"//div[contains(@class, 'gwt-ToggleButton') and not(contains(@class, '-disabled'))]"; |
531 |
188 |
getDriver().waitUntilCondition(new ExpectedCondition<Boolean>() |
532 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
533 |
386 |
@Override... |
534 |
|
public Boolean apply(WebDriver input) |
535 |
|
{ |
536 |
|
|
537 |
|
|
538 |
386 |
return !getSourceTextArea().isEnabled() |
539 |
|
&& getDriver().hasElementWithoutWaiting(By.xpath(enabledToolBarButtonXPath)); |
540 |
|
} |
541 |
|
}); |
542 |
|
} |
543 |
|
} |
544 |
|
|
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
549 |
369 |
public void switchToSource()... |
550 |
|
{ |
551 |
369 |
switchToSource(true); |
552 |
|
} |
553 |
|
|
554 |
|
|
555 |
|
|
556 |
|
|
557 |
|
@param |
558 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
559 |
376 |
public void switchToSource(boolean wait)... |
560 |
|
{ |
561 |
376 |
ensureElementIsNotCoveredByFloatingMenu(By.xpath(WYSIWYG_LOCATOR_FOR_SOURCE_TAB)); |
562 |
376 |
getSelenium().click(WYSIWYG_LOCATOR_FOR_SOURCE_TAB); |
563 |
376 |
if (wait) { |
564 |
369 |
getDriver().waitUntilCondition(new ExpectedCondition<Boolean>() |
565 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
566 |
370 |
@Override... |
567 |
|
public Boolean apply(WebDriver input) |
568 |
|
{ |
569 |
370 |
return getDriver().findElementWithoutWaiting(By.className("xPlainTextEditor")).isEnabled(); |
570 |
|
} |
571 |
|
}); |
572 |
|
|
573 |
369 |
getSourceTextArea().sendKeys(""); |
574 |
|
} |
575 |
|
} |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
@param |
581 |
|
@param |
582 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
583 |
57 |
public void typeInInput(String inputTitle, String text)... |
584 |
|
{ |
585 |
57 |
getSelenium().type("//input[@title=\"" + inputTitle + "\"]", text); |
586 |
|
} |
587 |
|
|
588 |
|
|
589 |
|
@param |
590 |
|
@return |
591 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
592 |
12 |
public String getInputValue(String inputTitle)... |
593 |
|
{ |
594 |
12 |
return getSelenium().getValue("//input[@title=\"" + inputTitle + "\"]"); |
595 |
|
} |
596 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
597 |
33 |
public boolean isPushButtonEnabled(String pushButtonTitle)... |
598 |
|
{ |
599 |
33 |
return getDriver().hasElementWithoutWaiting( |
600 |
|
By.xpath("//div[@title='" + pushButtonTitle + "' and @class='gwt-PushButton gwt-PushButton-up']")); |
601 |
|
} |
602 |
|
|
603 |
|
|
604 |
|
@param |
605 |
|
@return |
606 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
607 |
3 |
public boolean isToggleButtonEnabled(String toggleButtonTitle)... |
608 |
|
{ |
609 |
3 |
return getDriver().hasElementWithoutWaiting( |
610 |
|
By.xpath("//div[@title='" + toggleButtonTitle |
611 |
|
+ "' and contains(@class, 'gwt-ToggleButton') and not(contains(@class, '-disabled'))]")); |
612 |
|
} |
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
@param |
618 |
|
@param |
619 |
|
|
620 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
621 |
25 |
public void waitForPushButton(final String pushButtonTitle, final boolean enabled)... |
622 |
|
{ |
623 |
25 |
new Wait() |
624 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
625 |
33 |
public boolean until()... |
626 |
|
{ |
627 |
33 |
return enabled == isPushButtonEnabled(pushButtonTitle); |
628 |
|
} |
629 |
25 |
}.wait(pushButtonTitle + " button is not " + (enabled ? "enabled" : "disabled") + "!"); |
630 |
|
} |
631 |
|
|
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
@param |
636 |
|
@param |
637 |
|
|
638 |
|
|
|
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
639 |
3 |
public void waitForToggleButton(final String toggleButtonTitle, final boolean enabled)... |
640 |
|
{ |
641 |
3 |
new Wait() |
642 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
643 |
3 |
public boolean until()... |
644 |
|
{ |
645 |
3 |
return enabled == isToggleButtonEnabled(toggleButtonTitle); |
646 |
|
} |
647 |
3 |
}.wait(toggleButtonTitle + " button is not " + (enabled ? "enabled" : "disabled") + "!"); |
648 |
|
} |
649 |
|
|
650 |
|
|
651 |
|
|
652 |
|
|
653 |
|
|
654 |
|
@param |
655 |
|
@param |
656 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
657 |
51 |
public void waitForToggleButtonState(final String toggleButtonTitle, final boolean down)... |
658 |
|
{ |
659 |
51 |
new Wait() |
660 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
661 |
60 |
public boolean until()... |
662 |
|
{ |
663 |
60 |
return down == isToggleButtonDown(toggleButtonTitle); |
664 |
|
} |
665 |
|
}.wait("The state of the '" + toggleButtonTitle + "' toggle button didn't change!"); |
666 |
|
} |
667 |
|
|
668 |
|
|
669 |
|
@param |
670 |
|
@return |
671 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
672 |
61 |
public boolean isToggleButtonDown(String toggleButtonTitle)... |
673 |
|
{ |
674 |
61 |
return getDriver().hasElementWithoutWaiting( |
675 |
|
By.xpath("//div[@title='" + toggleButtonTitle + "' and @class='gwt-ToggleButton gwt-ToggleButton-down']")); |
676 |
|
} |
677 |
|
|
678 |
|
|
679 |
|
|
680 |
|
|
681 |
|
|
682 |
|
@param@link |
683 |
|
@return |
684 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
685 |
183 |
public boolean isMenuEnabled(String menuLabel)... |
686 |
|
{ |
687 |
183 |
return getDriver().hasElementWithoutWaiting( |
688 |
|
By.xpath("//td[contains(@class, 'gwt-MenuItem') and not(contains(@class, 'gwt-MenuItem-disabled'))]" |
689 |
|
+ "/div[@class = 'gwt-MenuItemLabel' and . = '" + menuLabel + "']")); |
690 |
|
} |
691 |
|
|
692 |
|
|
693 |
|
|
694 |
|
|
695 |
|
@param |
696 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
697 |
78 |
public void assertContent(String expectedHTML)... |
698 |
|
{ |
699 |
78 |
assertEquals(expectedHTML, getRichTextArea().getContent()); |
700 |
|
} |
701 |
|
|
702 |
|
|
703 |
|
|
704 |
|
|
705 |
|
@param |
706 |
|
@param |
707 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
|
708 |
104 |
public void moveCaret(String containerJSLocator, int offset)... |
709 |
|
{ |
710 |
104 |
StringBuilder script = new StringBuilder(); |
711 |
104 |
script.append("var range = document.createRange();\n"); |
712 |
104 |
script.append("range.setStart("); |
713 |
104 |
script.append(containerJSLocator); |
714 |
104 |
script.append(", "); |
715 |
104 |
script.append(offset); |
716 |
104 |
script.append(");\n"); |
717 |
104 |
script.append("range.collapse(true);\n"); |
718 |
104 |
script.append("window.getSelection().removeAllRanges();\n"); |
719 |
104 |
script.append("window.getSelection().addRange(range);"); |
720 |
104 |
getRichTextArea().executeScript(script.toString()); |
721 |
104 |
triggerToolbarUpdate(); |
722 |
|
} |
723 |
|
|
724 |
|
|
725 |
|
|
726 |
|
|
727 |
|
@param |
728 |
|
@param |
729 |
|
@param |
730 |
|
@param |
731 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
|
732 |
46 |
public void select(String startContainerJSLocator, int startOffset, String endContainerJSLocator, int endOffset)... |
733 |
|
{ |
734 |
46 |
StringBuilder script = new StringBuilder(); |
735 |
46 |
script.append("var range = document.createRange();\n"); |
736 |
46 |
script.append("range.setStart("); |
737 |
46 |
script.append(startContainerJSLocator); |
738 |
46 |
script.append(", "); |
739 |
46 |
script.append(startOffset); |
740 |
46 |
script.append(");\n"); |
741 |
46 |
script.append("range.setEnd("); |
742 |
46 |
script.append(endContainerJSLocator); |
743 |
46 |
script.append(", "); |
744 |
46 |
script.append(endOffset); |
745 |
46 |
script.append(");\n"); |
746 |
46 |
script.append("window.getSelection().removeAllRanges();\n"); |
747 |
46 |
script.append("window.getSelection().addRange(range);\n"); |
748 |
46 |
getRichTextArea().executeScript(script.toString()); |
749 |
46 |
triggerToolbarUpdate(); |
750 |
|
} |
751 |
|
|
752 |
|
|
753 |
|
|
754 |
|
|
755 |
|
@param |
756 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
757 |
22 |
public void selectNode(String jsLocator)... |
758 |
|
{ |
759 |
22 |
StringBuilder script = new StringBuilder(); |
760 |
22 |
script.append("var range = document.createRange();\n"); |
761 |
22 |
script.append("range.selectNode("); |
762 |
22 |
script.append(jsLocator); |
763 |
22 |
script.append(");\n"); |
764 |
22 |
script.append("window.getSelection().removeAllRanges();\n"); |
765 |
22 |
script.append("window.getSelection().addRange(range);\n"); |
766 |
|