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.diff; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.openqa.selenium.By; |
26 |
|
import org.openqa.selenium.WebElement; |
27 |
|
import org.xwiki.test.ui.po.BaseElement; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 5 |
Complexity Density: 0.42 |
|
37 |
|
public class EntityDiff extends BaseElement |
38 |
|
{ |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
private final WebElement container; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@param |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
49 |
10 |
public EntityDiff(WebElement container)... |
50 |
|
{ |
51 |
10 |
this.container = container; |
52 |
|
} |
53 |
|
|
54 |
|
|
55 |
|
@return |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
57 |
7 |
public List<String> getPropertyNames()... |
58 |
|
{ |
59 |
7 |
List<String> propertyNames = new ArrayList<>(); |
60 |
7 |
for (WebElement element : getDriver().findElementsWithoutWaiting(this.container, By.className("diff-header"))) { |
61 |
23 |
propertyNames.add(element.getText().trim()); |
62 |
|
} |
63 |
7 |
return propertyNames; |
64 |
|
} |
65 |
|
|
66 |
|
|
67 |
|
@param |
68 |
|
@return |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
70 |
25 |
public List<String> getDiff(String propertyName)... |
71 |
|
{ |
72 |
25 |
WebElement element = |
73 |
|
this.container.findElement(By.xpath(".//div[@class = 'diff-container' and " |
74 |
|
+ "parent::dd/preceding-sibling::dt[1][@class = 'diff-header' and normalize-space(.) = '" |
75 |
|
+ propertyName + "']]")); |
76 |
25 |
List<String> diff = new ArrayList<>(); |
77 |
25 |
for (WebElement line : getDriver().findElementsWithoutWaiting(element, By.xpath(".//td[3]"))) { |
78 |
81 |
if (getDriver().findElementsWithoutWaiting(line, By.tagName("ins")).size() > 0 |
79 |
|
|| getDriver().findElementsWithoutWaiting(line, By.tagName("del")).size() > 0) { |
80 |
15 |
diff.add(String.valueOf(getDriver().executeJavascript("return arguments[0].innerHTML", line))); |
81 |
|
} else { |
82 |
66 |
diff.add(line.getText()); |
83 |
|
} |
84 |
|
} |
85 |
25 |
return diff; |
86 |
|
} |
87 |
|
} |