1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.wysiwyg.test.po; |
21 |
|
|
22 |
|
import org.openqa.selenium.By; |
23 |
|
import org.openqa.selenium.WebElement; |
24 |
|
import org.openqa.selenium.interactions.Actions; |
25 |
|
import org.xwiki.test.ui.po.BaseElement; |
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
@version |
31 |
|
@since |
32 |
|
|
|
|
| 58.1% |
Uncovered Elements: 13 (31) |
Complexity: 10 |
Complexity Density: 0.53 |
|
33 |
|
public class MenuBarElement extends BaseElement |
34 |
|
{ |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
private static final String MENU_ITEM_XPATH = "//td[contains(@class, 'gwt-MenuItem') and . = '%s']"; |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
private final WebElement container; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@param |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
50 |
1 |
public MenuBarElement(WebElement container)... |
51 |
|
{ |
52 |
1 |
this.container = container; |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
0 |
public void clickImageMenu()... |
59 |
|
{ |
60 |
0 |
openMenuWithLabel("Image"); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
1 |
public void clickTableMenu()... |
67 |
|
{ |
68 |
1 |
openMenuWithLabel("Table"); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
@return |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
76 |
0 |
public AttachedImageSelectPane clickInsertAttachedImageMenu()... |
77 |
|
{ |
78 |
0 |
String xpath = String.format(MENU_ITEM_XPATH, "Attached Image..."); |
79 |
0 |
WebElement insertAttachedImageMenu = container.findElement(By.xpath(xpath)); |
80 |
0 |
if (!isMenuEnabled(insertAttachedImageMenu)) { |
81 |
0 |
return null; |
82 |
|
} |
83 |
0 |
insertAttachedImageMenu.click(); |
84 |
0 |
return new AttachedImageSelectPane().waitToLoad(); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
@return |
91 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
92 |
1 |
public TableConfigPane clickInsertTableMenu()... |
93 |
|
{ |
94 |
1 |
String xpath = String.format(MENU_ITEM_XPATH, "Insert Table..."); |
95 |
1 |
WebElement insertTableMenu = container.findElement(By.xpath(xpath)); |
96 |
1 |
if (!isMenuEnabled(insertTableMenu)) { |
97 |
0 |
return null; |
98 |
|
} |
99 |
1 |
insertTableMenu.click(); |
100 |
1 |
return new TableConfigPane().waitToLoad(); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
@param |
105 |
|
@return |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
1 |
private boolean isMenuEnabled(WebElement menu)... |
108 |
|
{ |
109 |
1 |
return !menu.getAttribute("class").contains("gwt-MenuItem-disabled"); |
110 |
|
} |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
@param |
116 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
117 |
1 |
private void openMenuWithLabel(String label)... |
118 |
|
{ |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
1 |
new Actions(getDriver()).moveToElement(container).perform(); |
124 |
1 |
clickMenuWithLabel(label); |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
@param |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
132 |
1 |
private void clickMenuWithLabel(String label)... |
133 |
|
{ |
134 |
1 |
container.findElement(By.xpath(String.format(MENU_ITEM_XPATH, label))).click(); |
135 |
|
} |
136 |
|
} |