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.HashMap; |
23 |
|
import java.util.List; |
24 |
|
import java.util.Map; |
25 |
|
|
26 |
|
import org.openqa.selenium.By; |
27 |
|
import org.openqa.selenium.WebElement; |
28 |
|
import org.openqa.selenium.support.FindBy; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
@version |
35 |
|
@since |
36 |
|
|
|
|
| 96% |
Uncovered Elements: 2 (50) |
Complexity: 16 |
Complexity Density: 0.64 |
|
37 |
|
public abstract class AbstractRegistrationPage extends BasePage |
38 |
|
{ |
39 |
|
@FindBy(id = "register") |
40 |
|
private WebElement registerFormElement; |
41 |
|
|
42 |
|
private FormElement form; |
43 |
|
|
44 |
|
public abstract void clickRegister(); |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
21 |
public void fillInJohnSmithValues()... |
47 |
|
{ |
48 |
21 |
fillRegisterForm("John", "Smith", "JohnSmith", "WeakPassword", "WeakPassword", "johnsmith@xwiki.org"); |
49 |
|
} |
50 |
|
|
|
|
| 93.9% |
Uncovered Elements: 2 (33) |
Complexity: 9 |
Complexity Density: 0.53 |
|
51 |
41 |
public void fillRegisterForm(final String firstName, final String lastName, final String username,... |
52 |
|
final String password, final String confirmPassword, final String email) |
53 |
|
{ |
54 |
41 |
Map<String, String> map = new HashMap<String, String>(); |
55 |
41 |
if (firstName != null) { |
56 |
24 |
map.put("register_first_name", firstName); |
57 |
|
} |
58 |
41 |
if (lastName != null) { |
59 |
24 |
map.put("register_last_name", lastName); |
60 |
|
} |
61 |
41 |
if (username != null) { |
62 |
29 |
map.put("xwikiname", username); |
63 |
|
} |
64 |
41 |
if (password != null) { |
65 |
29 |
map.put("register_password", password); |
66 |
|
} |
67 |
41 |
if (confirmPassword != null) { |
68 |
32 |
map.put("register2_password", confirmPassword); |
69 |
|
} |
70 |
41 |
if (email != null) { |
71 |
24 |
map.put("register_email", email); |
72 |
|
} |
73 |
41 |
getForm().fillFieldsByName(map); |
74 |
|
|
75 |
|
|
76 |
41 |
if (username != null) { |
77 |
29 |
while (!username.equals(getForm().getFieldValue(By.name("xwikiname")))) { |
78 |
0 |
getForm().setFieldValue(By.name("xwikiname"), username); |
79 |
|
} |
80 |
|
} |
81 |
|
} |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
83 |
70 |
private FormElement getForm()... |
84 |
|
{ |
85 |
70 |
if (this.form == null) { |
86 |
23 |
this.form = new FormElement(this.registerFormElement); |
87 |
|
} |
88 |
70 |
return this.form; |
89 |
|
} |
90 |
|
|
91 |
|
@return |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
16 |
public List<WebElement> getValidationFailureMessages()... |
93 |
|
{ |
94 |
16 |
return getDriver().findElementsWithoutWaiting(By.xpath("//dd/span[@class='LV_validation_message LV_invalid']")); |
95 |
|
} |
96 |
|
|
97 |
|
@return |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
18 |
public boolean validationFailureMessagesInclude(String message)... |
99 |
|
{ |
100 |
18 |
return getDriver().findElementsWithoutWaiting( |
101 |
|
By.xpath("//dd/span[@class='LV_validation_message LV_invalid' and . = '" + message + "']")).size() > 0; |
102 |
|
} |
103 |
|
|
104 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
12 |
public void triggerLiveValidation()... |
106 |
|
{ |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
12 |
getDriver().executeJavascript("try{ document.getElementById('register_first_name').focus(); " + |
111 |
|
"document.getElementById('register').onsubmit(null); }catch(err){}"); |
112 |
|
} |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
114 |
16 |
public boolean isLiveValidationEnabled()... |
115 |
|
{ |
116 |
16 |
return !getDriver().findElementsWithoutWaiting(By.xpath("//div[@id='mainContentArea']/script")).isEmpty(); |
117 |
|
} |
118 |
|
} |