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.List; |
23 |
|
|
24 |
|
import org.openqa.selenium.By; |
25 |
|
import org.openqa.selenium.WebElement; |
26 |
|
import org.openqa.selenium.support.FindBy; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@version |
32 |
|
@since |
33 |
|
|
|
|
| 78% |
Uncovered Elements: 13 (59) |
Complexity: 17 |
Complexity Density: 0.43 |
|
34 |
|
public class CommentsTab extends BaseElement |
35 |
|
{ |
36 |
|
@FindBy(xpath = "//fieldset[@id='commentform']/label/span") |
37 |
|
private WebElement commentAuthor; |
38 |
|
|
39 |
|
@FindBy(id = "XWiki.XWikiComments_author") |
40 |
|
private WebElement anonymousCommentAuthor; |
41 |
|
|
42 |
|
private ConfirmationModal confirmDelete; |
43 |
|
|
44 |
|
private List<WebElement> commentsList; |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
0 |
public String getCurrentAuthor()... |
47 |
|
{ |
48 |
0 |
return this.commentAuthor.getAttribute("value"); |
49 |
|
} |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
51 |
3 |
public boolean isCommentFormShown()... |
52 |
|
{ |
53 |
3 |
WebElement commentForm = getDriver().findElement( |
54 |
|
By.xpath("//form[@id='AddComment']/fieldset[@id='commentform']")); |
55 |
3 |
return commentForm.isDisplayed(); |
56 |
|
} |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
58 |
0 |
public void setAnonymousCommentAuthor(String author)... |
59 |
|
{ |
60 |
0 |
this.anonymousCommentAuthor.clear(); |
61 |
0 |
this.anonymousCommentAuthor.sendKeys(author); |
62 |
|
} |
63 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
64 |
18 |
public int getCommentID(String content)... |
65 |
|
{ |
66 |
18 |
this.commentsList = getDriver().findElementsWithoutWaiting(By.className("xwikicomment")); |
67 |
|
|
68 |
20 |
for (int i = 0; i < this.commentsList.size(); i++) { |
69 |
19 |
if (this.commentsList.get(i).findElement(By.className("commentcontent")).getText().equals(content)) { |
70 |
17 |
return Integer |
71 |
|
.parseInt(this.commentsList.get(i).getAttribute("id").substring("xwikicomment_".length())); |
72 |
|
} |
73 |
|
} |
74 |
1 |
return -1; |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
@return |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
11 |
public CommentForm getAddCommentForm()... |
81 |
|
{ |
82 |
11 |
return new CommentForm(By.id("AddComment")); |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
85 |
7 |
public int postComment(String content, boolean wait)... |
86 |
|
{ |
87 |
7 |
CommentForm addCommentForm = getAddCommentForm(); |
88 |
7 |
addCommentForm.getContentField().sendKeys(content); |
89 |
7 |
addCommentForm.clickSubmit(wait); |
90 |
7 |
return this.getCommentID(content); |
91 |
|
} |
92 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
93 |
0 |
public int postCommentAsGuest(String content, String author, boolean wait)... |
94 |
|
{ |
95 |
0 |
CommentForm addCommentForm = getAddCommentForm(); |
96 |
0 |
addCommentForm.getContentField().sendKeys(content); |
97 |
0 |
this.setAnonymousCommentAuthor(author); |
98 |
0 |
addCommentForm.clickSubmit(wait); |
99 |
0 |
return this.getCommentID(content); |
100 |
|
} |
101 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
102 |
3 |
public void deleteCommentByID(int id)... |
103 |
|
{ |
104 |
3 |
getDriver().findElement(By.xpath("//div[@id='xwikicomment_" + id |
105 |
|
+ "']//a[contains(@class, 'delete')]")).click(); |
106 |
3 |
this.confirmDelete = new ConfirmationModal(); |
107 |
3 |
this.confirmDelete.clickOk(); |
108 |
3 |
getDriver().waitUntilElementIsVisible( |
109 |
|
By.xpath("//div[contains(@class,'xnotification-done') and text()='Comment deleted']")); |
110 |
3 |
getDriver().findElement(By.xpath("//div[contains(@class,'xnotification-done') and text()='Comment deleted']")) |
111 |
|
.click(); |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
@param |
118 |
|
@return |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
120 |
2 |
public CommentForm replyToCommentByID(int id)... |
121 |
|
{ |
122 |
2 |
getDriver().findElementWithoutWaiting(By.xpath("//div[@id='xwikicomment_" |
123 |
|
+ id + "']//a[contains(@class, 'commentreply')]")).click(); |
124 |
2 |
return getAddCommentForm(); |
125 |
|
} |
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
127 |
2 |
public void replyToCommentByID(int id, String replyContent)... |
128 |
|
{ |
129 |
2 |
CommentForm replyCommentForm = replyToCommentByID(id); |
130 |
2 |
replyCommentForm.getContentField().sendKeys(replyContent); |
131 |
2 |
replyCommentForm.clickSubmit(); |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
@param |
138 |
|
@return |
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
140 |
2 |
public CommentForm editCommentByID(int id)... |
141 |
|
{ |
142 |
2 |
getDriver().findElementWithoutWaiting(By.xpath("//div[@id='xwikicomment_" |
143 |
|
+ id + "']//a[contains(@class, 'edit')]")).click(); |
144 |
2 |
getDriver().waitUntilElementIsVisible(By.id("XWiki.XWikiComments_" + id + "_comment")); |
145 |
2 |
return new CommentForm(By.className("edit-xcomment")); |
146 |
|
} |
147 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
148 |
2 |
public void editCommentByID(int id, String content)... |
149 |
|
{ |
150 |
2 |
CommentForm editCommentForm = editCommentByID(id); |
151 |
2 |
editCommentForm.getContentField().clear(); |
152 |
2 |
editCommentForm.getContentField().sendKeys(content); |
153 |
2 |
editCommentForm.clickSubmit(); |
154 |
|
} |
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
3 |
public String getCommentAuthorByID(int id)... |
157 |
|
{ |
158 |
3 |
return getDriver().findElementWithoutWaiting(By.xpath("//div[@id='xwikicomment_" |
159 |
|
+ id + "']//span[@class='commentauthor']")).getText(); |
160 |
|
} |
161 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
162 |
4 |
public String getCommentContentByID(int id)... |
163 |
|
{ |
164 |
4 |
return getDriver().findElementWithoutWaiting(By.xpath("//div[@id='xwikicomment_" |
165 |
|
+ id + "']//div[@class='commentcontent']")).getText(); |
166 |
|
} |
167 |
|
|
168 |
|
|
169 |
|
@since |
170 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
171 |
0 |
public boolean hasEditButtonForCommentByID(int commentId)... |
172 |
|
{ |
173 |
0 |
return getDriver().findElementsWithoutWaiting(By.xpath("//div[@id='xwikicomment_" |
174 |
|
+ commentId + "']//a[contains(@class, 'edit')]")).size() > 0; |
175 |
|
} |
176 |
|
} |