This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
/
CreateVersionGroupPage.java
98 lines (79 loc) · 2.9 KB
/
CreateVersionGroupPage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package org.zanata.page.groups;
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.zanata.page.BasePage;
import com.google.common.collect.ImmutableList;
/**
* @author Patrick Huang <a
* href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
@Slf4j
public class CreateVersionGroupPage extends BasePage {
@FindBy(id = "group-form:slugField:slug")
private WebElement groupSlugField;
@FindBy(id = "group-form:nameField:name")
private WebElement groupNameField;
@FindBy(id = "group-form:descriptionField:description")
private WebElement groupDescriptionField;
@FindBy(id = "group-form:group-create-new")
private WebElement saveButton;
public CreateVersionGroupPage(WebDriver driver) {
super(driver);
List<By> elementBys =
ImmutableList.<By> builder()
.add(By.id("group-form:slugField:slug"))
.add(By.id("group-form:nameField:name"))
.add(By.id("group-form:descriptionField:description"))
.add(By.id("group-form:group-create-new")).build();
waitForPage(elementBys);
}
public CreateVersionGroupPage inputGroupId(String groupId) {
groupSlugField.sendKeys(groupId);
return new CreateVersionGroupPage(getDriver());
}
public WebElement getInputGroupName() {
return groupNameField;
}
public WebElement getInputGroupId() {
return groupSlugField;
}
public WebElement getInputGroupDescription() {
return groupDescriptionField;
}
public CreateVersionGroupPage inputGroupName(String groupName) {
groupNameField.sendKeys(groupName);
return new CreateVersionGroupPage(getDriver());
}
public CreateVersionGroupPage inputGroupDescription(String desc) {
groupDescriptionField.sendKeys(desc);
return this;
}
public VersionGroupsPage saveGroup() {
clickAndCheckErrors(saveButton);
return new VersionGroupsPage(getDriver());
}
public CreateVersionGroupPage saveGroupFailure() {
clickAndCheckErrors(saveButton);
return new CreateVersionGroupPage(getDriver());
}
public CreateVersionGroupPage clearFields() {
groupSlugField.clear();
groupNameField.clear();
groupDescriptionField.clear();
return new CreateVersionGroupPage(getDriver());
}
public List<String> getFieldValidationErrors() {
List<WebElement> elements =
getDriver().findElements(By.className("message--danger"));
List<String> errors = new ArrayList<String>();
for (WebElement element : elements) {
errors.add(element.getText());
}
return errors;
}
}