blob: 45b6d16432b4d1c3c181aa2c6de4ce7f48d99392 (
plain)
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
|
package com.mavlushechka.a1qa.project.pages;
import aquality.selenium.browser.AqualityServices;
import aquality.selenium.elements.ElementType;
import aquality.selenium.elements.interfaces.IButton;
import aquality.selenium.elements.interfaces.ILabel;
import aquality.selenium.forms.Form;
import com.mavlushechka.a1qa.framework.utils.IntegerUtils;
import org.openqa.selenium.By;
import java.util.ArrayList;
import java.util.List;
public class ProjectsPage extends Form {
private final IButton addButton = AqualityServices.getElementFactory().getButton(By.xpath("//*[contains(@class,'panel-heading')]//a[@href='addProject']"), "Add project");
private final ILabel versionLabel = AqualityServices.getElementFactory().getLabel(By.xpath("//*[contains(@class,'footer-text')]//span"), "Version");
private final By byProjectLabel = By.xpath("//*[contains(@class,'list-group')]//a[contains(@class,'list-group-item')]");
private final String projectXpath = "//*[contains(@class,'panel')]//a[contains(@class,'list-group-item') and text()='%s']";
public ProjectsPage() {
super(By.xpath("//*[contains(@class,'panel')]"), "Projects");
}
public int getVersion() {
return IntegerUtils.parseInt(versionLabel.getText());
}
public List<String> getProjects() {
List<String> projects = new ArrayList<>();
AqualityServices.getElementFactory().findElements(byProjectLabel, ElementType.LABEL).forEach(element -> projects.add(element.getText()));
return projects;
}
public void openProject(String projectName) {
AqualityServices.getElementFactory().getButton(By.xpath(projectXpath.formatted(projectName)), "Project").clickAndWait();
}
public int getProjectId(String projectName) {
return Integer.parseInt(AqualityServices.getElementFactory().getButton(By.xpath(projectXpath.formatted(projectName)), "Project").getAttribute("id"));
}
public void clickOnAddButton() {
addButton.click();
}
}
|