1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.ui.po; |
21 |
|
|
22 |
|
import org.openqa.selenium.By; |
23 |
|
import org.openqa.selenium.WebElement; |
24 |
|
import org.openqa.selenium.support.FindBy; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
@version |
30 |
|
@since |
31 |
|
|
|
|
| 96.1% |
Uncovered Elements: 2 (51) |
Complexity: 18 |
Complexity Density: 0.62 |
|
32 |
|
public class InlinePage extends ViewPage |
33 |
|
{ |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
private static final String FIELD_XPATH_FORMAT = "//*[substring(@name, string-length(@name) - %s - 2) = '_0_%s']"; |
38 |
|
|
39 |
|
@FindBy(name = "action_preview") |
40 |
|
private WebElement preview; |
41 |
|
|
42 |
|
@FindBy(name = "action_saveandcontinue") |
43 |
|
private WebElement saveandcontinue; |
44 |
|
|
45 |
|
@FindBy(name = "action_save") |
46 |
|
private WebElement save; |
47 |
|
|
48 |
|
@FindBy(name = "action_cancel") |
49 |
|
private WebElement cancel; |
50 |
|
|
51 |
|
@FindBy(id = "inline") |
52 |
|
private WebElement form; |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
1 |
public void clickPreview()... |
55 |
|
{ |
56 |
1 |
preview.click(); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
11 |
public void clickSaveAndContinue()... |
60 |
|
{ |
61 |
11 |
clickSaveAndContinue(true); |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
@link |
66 |
|
|
67 |
|
|
68 |
|
@param |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
70 |
12 |
public void clickSaveAndContinue(boolean wait)... |
71 |
|
{ |
72 |
12 |
getSaveAndContinueButton().click(); |
73 |
|
|
74 |
12 |
if (wait) { |
75 |
|
|
76 |
11 |
waitForNotificationSuccessMessage("Saved"); |
77 |
|
} |
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
@link@link |
82 |
|
@link |
83 |
|
|
84 |
|
@return |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
3 |
public WebElement getSaveAndContinueButton()... |
87 |
|
{ |
88 |
3 |
return saveandcontinue; |
89 |
|
} |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
91 |
46 |
public <T extends ViewPage> T clickSaveAndView()... |
92 |
|
{ |
93 |
46 |
clickSaveAndView(true); |
94 |
|
|
95 |
46 |
return createViewPage(); |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
@param |
103 |
|
@since |
104 |
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
105 |
46 |
public void clickSaveAndView(boolean wait)... |
106 |
|
{ |
107 |
46 |
if (wait) { |
108 |
46 |
getDriver().addPageNotYetReloadedMarker(); |
109 |
|
} |
110 |
|
|
111 |
46 |
this.getSaveAndViewButton().click(); |
112 |
|
|
113 |
46 |
if (wait) { |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
46 |
getDriver().waitUntilPageIsReloaded(); |
118 |
|
} |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
@link@link |
123 |
|
@link |
124 |
|
|
125 |
|
@return |
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
25 |
public WebElement getSaveAndViewButton()... |
128 |
|
{ |
129 |
25 |
return save; |
130 |
|
} |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
132 |
6 |
public <T extends ViewPage> T clickCancel()... |
133 |
|
{ |
134 |
6 |
cancel.click(); |
135 |
6 |
return createViewPage(); |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
@link |
140 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
42 |
protected <T extends ViewPage> T createViewPage()... |
142 |
|
{ |
143 |
42 |
return (T) new ViewPage(); |
144 |
|
} |
145 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
146 |
6 |
@Override... |
147 |
|
public String getContent() |
148 |
|
{ |
149 |
6 |
return form.getText(); |
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
|
@return |
154 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
155 |
57 |
public WebElement getForm()... |
156 |
|
{ |
157 |
57 |
return form; |
158 |
|
} |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
@param |
164 |
|
@return |
165 |
|
@since |
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
167 |
7 |
public String getValue(String fieldName)... |
168 |
|
{ |
169 |
7 |
String xpath = String.format(FIELD_XPATH_FORMAT, fieldName.length(), fieldName); |
170 |
7 |
return new FormElement(getForm()).getFieldValue(By.xpath(xpath)); |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
@param |
177 |
|
@param |
178 |
|
@since |
179 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
180 |
9 |
public void setValue(String fieldName, String fieldValue)... |
181 |
|
{ |
182 |
9 |
String xpath = String.format(FIELD_XPATH_FORMAT, fieldName.length(), fieldName); |
183 |
9 |
WebElement field = getForm().findElement(By.xpath(xpath)); |
184 |
9 |
if (field.getAttribute("name").equals(field.getAttribute("id"))) { |
185 |
7 |
new FormElement(getForm()).setFieldValue(field, fieldValue); |
186 |
|
} else { |
187 |
2 |
xpath = String.format("//*[@name = '%s' and @value = '%s']", field.getAttribute("name"), fieldValue); |
188 |
2 |
new FormElement(getForm()).setCheckBox(By.xpath(xpath), true); |
189 |
|
} |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
@since |
194 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
195 |
113 |
@Override... |
196 |
|
public void waitUntilPageJSIsLoaded() |
197 |
|
{ |
198 |
113 |
super.waitUntilPageJSIsLoaded(); |
199 |
|
|
200 |
|
|
201 |
113 |
getDriver().waitUntilJavascriptCondition( |
202 |
|
"return XWiki.actionButtons != undefined && " + "XWiki.actionButtons.EditActions != undefined && " |
203 |
|
+ "XWiki.actionButtons.AjaxSaveAndContinue != undefined"); |
204 |
|
} |
205 |
|
|
206 |
|
} |