1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.appwithinminutes.test.po; |
21 |
|
|
22 |
|
import org.openqa.selenium.By; |
23 |
|
import org.openqa.selenium.Keys; |
24 |
|
import org.openqa.selenium.WebElement; |
25 |
|
import org.openqa.selenium.interactions.Actions; |
26 |
|
import org.xwiki.test.ui.po.BaseElement; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@version |
32 |
|
@since |
33 |
|
|
|
|
| 87.1% |
Uncovered Elements: 4 (31) |
Complexity: 9 |
Complexity Density: 0.41 |
|
34 |
|
public class StaticListItemsEditor extends BaseElement |
35 |
|
{ |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
private WebElement container; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
private WebElement valueInput; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
private WebElement labelInput; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
private WebElement addButton; |
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
@param |
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
61 |
1 |
public StaticListItemsEditor(WebElement container)... |
62 |
|
{ |
63 |
1 |
this.container = container; |
64 |
|
|
65 |
1 |
By xpath = By.xpath(".//*[@class = 'xHint' and . = 'ID']/following-sibling::input[@type = 'text']"); |
66 |
1 |
valueInput = getDriver().findElementWithoutWaiting(container, xpath); |
67 |
|
|
68 |
1 |
xpath = By.xpath(".//*[@class = 'xHint' and . = 'Value']/following-sibling::input[@type = 'text']"); |
69 |
1 |
labelInput = getDriver().findElementWithoutWaiting(container, xpath); |
70 |
|
|
71 |
1 |
addButton = getDriver().findElementWithoutWaiting(container, By.className("add")); |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
@param |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
79 |
1 |
public void remove(String value)... |
80 |
|
{ |
81 |
1 |
By xpath = By.xpath("ul/li/*[@title = '" + value + "']/following-sibling::*[@class = 'delete']"); |
82 |
1 |
getDriver().findElementWithoutWaiting(container, xpath).click(); |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
@param |
89 |
|
@param |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
91 |
2 |
public void add(String value, String label)... |
92 |
|
{ |
93 |
2 |
valueInput.clear(); |
94 |
2 |
valueInput.sendKeys(value); |
95 |
2 |
labelInput.clear(); |
96 |
2 |
labelInput.sendKeys(label); |
97 |
2 |
addButton.click(); |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
@return |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
103 |
0 |
public WebElement getValueInput()... |
104 |
|
{ |
105 |
0 |
return valueInput; |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
@return |
110 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0 |
public WebElement getLabelInput()... |
112 |
|
{ |
113 |
0 |
return labelInput; |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
@param |
120 |
|
@param |
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
122 |
1 |
public void setLabel(String value, String newLabel)... |
123 |
|
{ |
124 |
1 |
getItem(value).click(); |
125 |
1 |
labelInput.clear(); |
126 |
1 |
labelInput.sendKeys(newLabel + Keys.RETURN); |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@param |
133 |
|
@param |
134 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
1 |
public void moveBefore(String valueToMove, String beforeValue)... |
136 |
|
{ |
137 |
1 |
new Actions(getDriver()).clickAndHold(getItem(valueToMove)) |
138 |
|
.moveToElement(getItem(beforeValue), 0, 0).release().perform(); |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
@param |
143 |
|
@return |
144 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
145 |
3 |
public WebElement getItem(String valueOrLabel)... |
146 |
|
{ |
147 |
3 |
By xpath = By.xpath("ul/li/*[@title = '" + valueOrLabel + "' or . = '" + valueOrLabel + "']"); |
148 |
3 |
return getDriver().findElementWithoutWaiting(container, xpath); |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
@return |
153 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
154 |
1 |
public int size()... |
155 |
|
{ |
156 |
1 |
return getDriver().findElementsWithoutWaiting(container, By.tagName("li")).size(); |
157 |
|
} |
158 |
|
} |