| 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 |
|
|
| |
|
| 0% |
Uncovered Elements: 37 (37) |
Complexity: 16 |
Complexity Density: 0.8 |
|
| 32 |
|
public class EntityTreeElement extends BaseElement |
| 33 |
|
{ |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
@FindBy(xpath = "//div[@class = 'listGrid']/following-sibling::input") |
| 38 |
|
private WebElement input; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
@param |
| 44 |
|
@return |
| 45 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
0 |
public EntityTreeElement waitForSpace(String spaceName)... |
| 47 |
|
{ |
| 48 |
0 |
return waitForSpace(spaceName, false); |
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
@param |
| 55 |
|
@param |
| 56 |
|
@return |
| 57 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 58 |
0 |
public EntityTreeElement waitForSpace(String spaceName, boolean selected)... |
| 59 |
|
{ |
| 60 |
0 |
return waitForNodeWithHintAndLabel("Located in xwiki \u00BB " + spaceName, spaceName, selected); |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
@param |
| 65 |
|
@return |
| 66 |
|
|
| 67 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 68 |
0 |
public boolean hasSpace(String spaceName)... |
| 69 |
|
{ |
| 70 |
0 |
return hasNodeWithHintAndLabel("Located in xwiki \u00BB " + spaceName, spaceName); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
@param |
| 78 |
|
@param |
| 79 |
|
@return |
| 80 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 81 |
0 |
public EntityTreeElement waitForPage(String spaceName, String pageName)... |
| 82 |
|
{ |
| 83 |
0 |
return waitForPage(spaceName, pageName, false); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
@param |
| 90 |
|
@param |
| 91 |
|
@param |
| 92 |
|
@return |
| 93 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
0 |
public EntityTreeElement waitForPage(String spaceName, String pageName, String pageTitle)... |
| 95 |
|
{ |
| 96 |
0 |
return waitForPage(spaceName, pageName, pageTitle, false); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
@param |
| 104 |
|
@param |
| 105 |
|
@param |
| 106 |
|
@return |
| 107 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 108 |
0 |
public EntityTreeElement waitForPage(String spaceName, String pageName, boolean selected)... |
| 109 |
|
{ |
| 110 |
0 |
return waitForPage(spaceName, pageName, pageName, selected); |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
@param |
| 117 |
|
@param |
| 118 |
|
@param |
| 119 |
|
@param |
| 120 |
|
@return |
| 121 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 122 |
0 |
public EntityTreeElement waitForPage(String spaceName, String pageName, String pageTitle, boolean selected)... |
| 123 |
|
{ |
| 124 |
0 |
return waitForNodeWithHintAndLabel(String.format("Located in xwiki \u00BB %s \u00BB %s", spaceName, pageName), |
| 125 |
|
pageTitle, selected); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
|
| 129 |
|
@param |
| 130 |
|
@param |
| 131 |
|
@return |
| 132 |
|
|
| 133 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 134 |
0 |
public boolean hasPage(String spaceName, String pageName)... |
| 135 |
|
{ |
| 136 |
0 |
return hasPage(spaceName, pageName, pageName); |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
@param |
| 141 |
|
@param |
| 142 |
|
@param |
| 143 |
|
@return |
| 144 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 145 |
0 |
public boolean hasPage(String spaceName, String pageName, String pageTitle)... |
| 146 |
|
{ |
| 147 |
0 |
return hasNodeWithHintAndLabel(String.format("Located in xwiki \u00BB %s \u00BB %s", spaceName, pageName), |
| 148 |
|
pageTitle); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
@param |
| 155 |
|
@param |
| 156 |
|
@param |
| 157 |
|
@return |
| 158 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 159 |
0 |
public EntityTreeElement waitForAttachment(String spaceName, String pageName, String fileName)... |
| 160 |
|
{ |
| 161 |
0 |
return waitForAttachment(spaceName, pageName, fileName, false); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
@param |
| 168 |
|
@param |
| 169 |
|
@param |
| 170 |
|
@param |
| 171 |
|
@return |
| 172 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 173 |
0 |
public EntityTreeElement waitForAttachment(String spaceName, String pageName, String fileName, boolean selected)... |
| 174 |
|
{ |
| 175 |
0 |
return waitForNodeWithHintAndLabel(String.format("Attached to xwiki \u00BB %s \u00BB %s", spaceName, pageName), |
| 176 |
|
fileName, selected); |
| 177 |
|
} |
| 178 |
|
|
| 179 |
|
|
| 180 |
|
@param |
| 181 |
|
@param |
| 182 |
|
@param |
| 183 |
|
@return |
| 184 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 185 |
0 |
public boolean hasAttachment(String spaceName, String pageName, String fileName)... |
| 186 |
|
{ |
| 187 |
0 |
return hasNodeWithHintAndLabel(String.format("Attached to xwiki \u00BB %s \u00BB %s", spaceName, pageName), |
| 188 |
|
fileName); |
| 189 |
|
} |
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
@param |
| 196 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 197 |
0 |
public void lookupEntity(String entityReference)... |
| 198 |
|
{ |
| 199 |
0 |
input.clear(); |
| 200 |
0 |
input.sendKeys(entityReference); |
| 201 |
|
} |
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
@param |
| 207 |
|
@param |
| 208 |
|
@param |
| 209 |
|
|
| |
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 210 |
0 |
private EntityTreeElement waitForNodeWithHintAndLabel(String hint, String label, boolean selected)... |
| 211 |
|
{ |
| 212 |
0 |
String className = selected ? "treeCellSelected" : "treeCell"; |
| 213 |
0 |
String xpath = |
| 214 |
|
String.format("//td[contains(@class, '%s')]//*[@title = '%s' and . = '%s']", className, hint, label); |
| 215 |
0 |
getDriver().waitUntilElementIsVisible(By.xpath(xpath)); |
| 216 |
0 |
return this; |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
@param |
| 223 |
|
@param |
| 224 |
|
@return |
| 225 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 226 |
0 |
private boolean hasNodeWithHintAndLabel(String hint, String label)... |
| 227 |
|
{ |
| 228 |
0 |
String format = "//td[starts-with(@class, 'treeCell')]//*[@title = '%s' and . = '%s']"; |
| 229 |
|
|
| 230 |
|
|
| 231 |
0 |
return getDriver().findElementsWithoutWaiting(By.xpath(String.format(format, hint, label))).size() == 1; |
| 232 |
|
} |
| 233 |
|
} |