1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.tag.test.po; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import org.openqa.selenium.By; |
25 |
|
import org.openqa.selenium.WebElement; |
26 |
|
import org.openqa.selenium.support.FindBy; |
27 |
|
import org.xwiki.test.ui.po.ViewPage; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
|
|
| 90.5% |
Uncovered Elements: 2 (21) |
Complexity: 6 |
Complexity Density: 0.43 |
|
35 |
|
public class TaggablePage extends ViewPage |
36 |
|
{ |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@FindBy(id = "xdocTags") |
41 |
|
private WebElement tagsContainer; |
42 |
|
|
43 |
|
|
44 |
|
@return |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
33 |
public boolean hasTag(String tagName)... |
47 |
|
{ |
48 |
33 |
return getDriver().findElementsWithoutWaiting(this.tagsContainer, getTagLocator(tagName)).size() > 0; |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
|
@param |
53 |
|
@return |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
36 |
private By getTagLocator(String tagName)... |
56 |
|
{ |
57 |
36 |
return By.xpath("//*[@class = 'tag' and . = '" + tagName + "']"); |
58 |
|
} |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
@param |
64 |
|
@return |
65 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
66 |
3 |
public boolean removeTag(String tagName)... |
67 |
|
{ |
68 |
3 |
List<WebElement> toDelete = getDriver().findElementsWithoutWaiting(this.tagsContainer, |
69 |
|
By.xpath("//a[contains(@href, '&tag=" + tagName + "') and . = 'X']")); |
70 |
3 |
if (toDelete.size() > 0) { |
71 |
3 |
toDelete.get(0).click(); |
72 |
3 |
getDriver().waitUntilElementDisappears(getTagLocator(tagName)); |
73 |
3 |
return true; |
74 |
|
} |
75 |
0 |
return false; |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@return |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
83 |
12 |
public AddTagsPane addTags()... |
84 |
|
{ |
85 |
12 |
this.tagsContainer.findElement(By.linkText("[+]")).click(); |
86 |
12 |
getDriver().waitUntilElementDisappears(By.xpath("//*[@id = 'xdocTags']//a[. = '[+]']")); |
87 |
12 |
return new AddTagsPane(); |
88 |
|
} |
89 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
90 |
2 |
public TagPage clickOnTag(String tagName)... |
91 |
|
{ |
92 |
2 |
WebElement tag = getDriver().findElementWithoutWaiting( |
93 |
|
By.xpath("//span[@class='tag']/a[. = '" + tagName + "' ]")); |
94 |
2 |
tag.click(); |
95 |
2 |
return new TagPage(); |
96 |
|
} |
97 |
|
} |