1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.annotation.test.po; |
21 |
|
|
22 |
|
import org.openqa.selenium.By; |
23 |
|
import org.openqa.selenium.Keys; |
24 |
|
import org.openqa.selenium.WebElement; |
25 |
|
import org.openqa.selenium.interactions.Actions; |
26 |
|
import org.openqa.selenium.support.FindBy; |
27 |
|
import org.xwiki.test.ui.po.BaseElement; |
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
@version |
33 |
|
@since |
34 |
|
|
35 |
|
|
|
|
| 74.4% |
Uncovered Elements: 10 (39) |
Complexity: 10 |
Complexity Density: 0.34 |
|
36 |
|
public class AnnotationsLabel extends BaseElement |
37 |
|
{ |
38 |
|
|
39 |
|
@FindBy(xpath = "//a[@title='Delete this annotation']") |
40 |
|
private WebElement deleteAnnotation; |
41 |
|
|
42 |
|
@FindBy(xpath = "//span[@class='annotationAuthor']") |
43 |
|
private WebElement annotationAuthor; |
44 |
|
|
45 |
|
@FindBy(xpath = "annotationDate") |
46 |
|
private WebElement annotationDate; |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
48 |
4 |
private void hoverOnAnnotationByText(String searchText)... |
49 |
|
{ |
50 |
4 |
hoverOnAnnotationById(getAnnotationIdByText(searchText)); |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
53 |
8 |
private void hoverOnAnnotationById(String annotationId)... |
54 |
|
{ |
55 |
8 |
WebElement annotationIcon = getDriver().findElement(By.id(annotationId)); |
56 |
|
|
57 |
|
|
58 |
8 |
Actions builder = new Actions(getDriver()); |
59 |
8 |
builder.moveToElement(annotationIcon).build().perform(); |
60 |
|
|
61 |
8 |
getDriver().waitUntilElementIsVisible(By.className("annotation-box-view")); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
4 |
private void showAnnotationById(String idText)... |
65 |
|
{ |
66 |
4 |
hoverOnAnnotationById(idText); |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0 |
private void showAnnotationByText(String searchText)... |
70 |
|
{ |
71 |
0 |
showAnnotationById(getAnnotationIdByText(searchText)); |
72 |
|
} |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
0 |
public void deleteAnnotationByText(String searchText)... |
75 |
|
{ |
76 |
0 |
this.deleteAnnotationById(this.getAnnotationIdByText(searchText)); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
79 |
4 |
public void deleteAnnotationById(String idText)... |
80 |
|
{ |
81 |
4 |
this.showAnnotationById(idText); |
82 |
4 |
this.deleteAnnotation.click(); |
83 |
4 |
getDriver().waitUntilElementIsVisible(By.xpath("//input[@value='Yes']")); |
84 |
4 |
getDriver().findElement(By.xpath("//input[@value='Yes']")).click(); |
85 |
|
} |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
87 |
0 |
public String getAnnotationsAuthorByText(String searchText)... |
88 |
|
{ |
89 |
0 |
this.hoverOnAnnotationByText(searchText); |
90 |
0 |
return this.annotationAuthor.getText(); |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
93 |
0 |
public String getAnnotationAuthorById(String idText)... |
94 |
|
{ |
95 |
0 |
this.showAnnotationById(idText); |
96 |
0 |
return this.annotationAuthor.getText(); |
97 |
|
} |
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
99 |
8 |
public String getAnnotationIdByText(String searchText)... |
100 |
|
{ |
101 |
8 |
getDriver().waitUntilElementIsVisible(By.xpath("//span[contains(.,'" + searchText + "')]")); |
102 |
8 |
WebElement annotation = getDriver().findElement(By.xpath("//span[contains(.,'" + searchText + "')]")); |
103 |
8 |
String classId = annotation.getAttribute("class"); |
104 |
8 |
classId = classId.split("\\s+")[1]; |
105 |
8 |
return classId; |
106 |
|
} |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
108 |
4 |
public String getAnnotationContentByText(String searchText)... |
109 |
|
{ |
110 |
4 |
hoverOnAnnotationByText(searchText); |
111 |
4 |
getDriver().waitUntilElementIsVisible(By.xpath("//div[@class='annotationText']/p")); |
112 |
4 |
String annotationContent = |
113 |
|
getDriver().findElement(By.xpath("//*[@class='annotation-bubble']//div[@class='annotationText']/p")) |
114 |
|
.getText(); |
115 |
4 |
WebElement body = getDriver().findElement(By.id("body")); |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
4 |
body.sendKeys(Keys.ESCAPE); |
120 |
4 |
body.sendKeys(Keys.ESCAPE); |
121 |
4 |
getDriver().waitUntilElementDisappears(By.className("annotation-box-view")); |
122 |
4 |
return annotationContent; |
123 |
|
} |
124 |
|
} |