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 org.openqa.selenium.WebElement; |
23 |
|
import org.openqa.selenium.support.FindBy; |
24 |
|
import org.xwiki.test.ui.TestUtils; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
@version |
30 |
|
@since |
31 |
|
|
|
|
| 80% |
Uncovered Elements: 4 (20) |
Complexity: 8 |
Complexity Density: 0.73 |
|
32 |
|
public class LoginPage extends ViewPage |
33 |
|
{ |
34 |
|
@FindBy(id = "j_username") |
35 |
|
private WebElement usernameText; |
36 |
|
|
37 |
|
@FindBy(id = "j_password") |
38 |
|
private WebElement passwordText; |
39 |
|
|
40 |
|
@FindBy(id = "rememberme") |
41 |
|
private WebElement rememberMeCheckbox; |
42 |
|
|
43 |
|
@FindBy(xpath = "//input[@type='submit' and @value='Log-in']") |
44 |
|
private WebElement submitButton; |
45 |
|
|
46 |
|
@FindBy(xpath = "//div[@class='errormessage']") |
47 |
|
private WebElement loginErrorDiv; |
48 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
49 |
0 |
public static LoginPage gotoPage()... |
50 |
|
{ |
51 |
0 |
getUtil().gotoPage("XWiki", "XWikiLogin", "login"); |
52 |
0 |
return new LoginPage(); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
55 |
6 |
public void loginAsAdmin()... |
56 |
|
{ |
57 |
6 |
loginAs(TestUtils.ADMIN_CREDENTIALS.getUserName(), TestUtils.ADMIN_CREDENTIALS.getPassword(), true); |
58 |
|
} |
59 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 4 |
Complexity Density: 0.67 |
|
60 |
9 |
public void loginAs(String username, String password, boolean rememberMe)... |
61 |
|
{ |
62 |
|
|
63 |
9 |
if (!isAuthenticated() || !getCurrentUser().equals(username)) { |
64 |
9 |
this.usernameText.sendKeys(username); |
65 |
9 |
this.passwordText.sendKeys(password); |
66 |
9 |
if (rememberMe) { |
67 |
6 |
this.rememberMeCheckbox.click(); |
68 |
|
} |
69 |
9 |
this.submitButton.click(); |
70 |
|
} |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
73 |
3 |
public void loginAs(String username, String password)... |
74 |
|
{ |
75 |
3 |
loginAs(username, password, false); |
76 |
|
} |
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
2 |
public boolean hasInvalidCredentialsErrorMessage()... |
79 |
|
{ |
80 |
2 |
return this.loginErrorDiv.getText().equals("Error: Invalid credentials"); |
81 |
|
} |
82 |
|
} |