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 java.util.ArrayList; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import org.apache.commons.lang.StringUtils; |
26 |
|
import org.openqa.selenium.By; |
27 |
|
import org.openqa.selenium.WebElement; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 9 |
Complexity Density: 0.45 |
|
35 |
|
public class BreadcrumbElement extends BaseElement |
36 |
|
{ |
37 |
|
private WebElement container; |
38 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
39 |
61 |
public BreadcrumbElement(WebElement container)... |
40 |
|
{ |
41 |
61 |
this.container = container; |
42 |
|
} |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
44 |
44 |
public List<String> getPath()... |
45 |
|
{ |
46 |
44 |
List<WebElement> pathElements = getDriver().findElementsWithoutWaiting(this.container, By.tagName("li")); |
47 |
44 |
List<String> path = new ArrayList<>(); |
48 |
44 |
for (WebElement pathElement : pathElements) { |
49 |
166 |
path.add(pathElement.getText()); |
50 |
|
} |
51 |
44 |
return path; |
52 |
|
} |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
32 |
public String getPathAsString()... |
55 |
|
{ |
56 |
32 |
return StringUtils.join(getPath(), '/'); |
57 |
|
} |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
17 |
public void clickPathElement(String linkText)... |
60 |
|
{ |
61 |
17 |
this.container.findElement(By.linkText(linkText)).click(); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
64 |
24 |
public boolean hasPathElement(String text, boolean isCurrent, boolean withLink)... |
65 |
|
{ |
66 |
24 |
List<WebElement> result; |
67 |
24 |
if (isCurrent) { |
68 |
2 |
result = getDriver().findElementsWithoutWaiting(this.container, |
69 |
|
By.xpath("li[contains(@class, 'active')]/a[. = '" + text + "']")); |
70 |
|
} else { |
71 |
22 |
if (withLink) { |
72 |
21 |
result = getDriver().findElementsWithoutWaiting(this.container, By.xpath("//a[. = '" + text + "']")); |
73 |
|
} else { |
74 |
|
|
75 |
|
|
76 |
1 |
result = getDriver().findElementsWithoutWaiting(this.container, By.xpath("//li[. = '" + text + "']")); |
77 |
|
} |
78 |
|
} |
79 |
24 |
return result.size() > 0; |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
82 |
5 |
public void expand()... |
83 |
|
{ |
84 |
|
|
85 |
5 |
final String containerId = this.container.getAttribute("id"); |
86 |
|
|
87 |
5 |
clickPathElement("…"); |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
5 |
getDriver().waitUntilElementDisappears(By.cssSelector("#" + containerId + " .ellipsis")); |
92 |
|
|
93 |
|
|
94 |
5 |
this.container = getDriver().findElementById(containerId); |
95 |
|
} |
96 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
14 |
public boolean canBeExpanded()... |
98 |
|
{ |
99 |
14 |
return hasPathElement("…", false, true); |
100 |
|
} |
101 |
|
} |