1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.invitation.test.po; |
21 |
|
|
22 |
|
import org.openqa.selenium.By; |
23 |
|
import org.openqa.selenium.WebDriverException; |
24 |
|
import org.openqa.selenium.WebElement; |
25 |
|
import org.openqa.selenium.support.FindBy; |
26 |
|
import org.xwiki.test.ui.po.BaseElement; |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
@version |
32 |
|
@since |
33 |
|
|
|
|
| 84.6% |
Uncovered Elements: 4 (26) |
Complexity: 8 |
Complexity Density: 0.53 |
|
34 |
|
public class InvitationFooterElement extends BaseElement |
35 |
|
{ |
36 |
|
@FindBy(id = "invitation-footer") |
37 |
|
private WebElement footer; |
38 |
|
|
39 |
|
@FindBy(xpath = "//div[@id='invitation-footer']//a[@href='/xwiki/bin/view/Invitation/InvitationMemberActions?inspect=all']") |
40 |
|
private WebElement inspectAll; |
41 |
|
|
42 |
|
@FindBy(xpath = "//div[@id='invitation-footer']//a[@href='/xwiki/bin/view/Invitation/InvitationMemberActions?inspect=allAsAdmin']") |
43 |
|
private WebElement inspectAllAsAdmin; |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
45 |
1 |
public boolean isAdmin()... |
46 |
|
{ |
47 |
1 |
return !getDriver().findElementsWithoutWaiting(this.footer, By.id("HAdministrativeTools")).isEmpty(); |
48 |
|
} |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
50 |
2 |
public InspectInvitationsPage inspectMyInvitations()... |
51 |
|
{ |
52 |
2 |
this.inspectAll.click(); |
53 |
2 |
return new InspectInvitationsPage.AsUser(); |
54 |
|
} |
55 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
56 |
1 |
public InspectInvitationsPage inspectAllInvitations()... |
57 |
|
{ |
58 |
1 |
if (!isAdmin()) { |
59 |
0 |
throw new WebDriverException("Inspection as admin impossible because user is not admin."); |
60 |
|
} |
61 |
1 |
this.inspectAllAsAdmin.click(); |
62 |
1 |
return new InspectInvitationsPage.AsAdmin(); |
63 |
|
} |
64 |
|
|
|
|
| 66.7% |
Uncovered Elements: 2 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
65 |
4 |
public int myPendingInvitations()... |
66 |
|
{ |
67 |
4 |
if (getDriver().findElementsWithoutWaiting(this.footer, By.id("my-pending-invitations")).size() == 0) |
68 |
|
{ |
69 |
0 |
return 0; |
70 |
|
} |
71 |
4 |
String message = getDriver().findElementsWithoutWaiting(this.footer, |
72 |
|
By.id("my-pending-invitations")).get(0).getText().trim(); |
73 |
4 |
return Integer.parseInt(message.substring(0, message.indexOf(" pending"))); |
74 |
|
} |
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
76 |
2 |
public int spamReports()... |
77 |
|
{ |
78 |
2 |
if (getDriver().findElementsWithoutWaiting(this.footer, By.id("spam-reports")).size() == 0) { |
79 |
1 |
return 0; |
80 |
|
} |
81 |
1 |
String message = getDriver().findElementsWithoutWaiting(this.footer, |
82 |
|
By.id("spam-reports")).get(0).getText().trim(); |
83 |
1 |
return Integer.parseInt(message.substring(0, message.indexOf(" reported as spam"))); |
84 |
|
} |
85 |
|
} |