summaryrefslogtreecommitdiff
path: root/src/main/java/com/mavlushechka/a1qa/project/pages/AddProjectPage.java
blob: 0981f6040086ea4a8aad05d246628ec9b2e1e78d (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
package com.mavlushechka.a1qa.project.pages;

import aquality.selenium.browser.AqualityServices;
import aquality.selenium.elements.interfaces.IButton;
import aquality.selenium.elements.interfaces.ILabel;
import aquality.selenium.elements.interfaces.ITextBox;
import aquality.selenium.forms.Form;
import org.openqa.selenium.By;

public class AddProjectPage extends Form {


    private final ITextBox projectNameBox = AqualityServices.getElementFactory().getTextBox(By.id("projectName"), "Project name");
    private final IButton saveProjectButton = AqualityServices.getElementFactory().getButton(
            By.xpath("//*[@id='addProjectForm']//button[contains(@class,'btn-primary')]"), "Save project"
    );
    private final ILabel projectSavedLabel = AqualityServices.getElementFactory().getLabel(
            By.xpath("//*[@id='addProjectForm']//*[contains(@class,'alert-success')]"), "Project saved"
    );


    public AddProjectPage() {
        super(By.id("addProjectForm"), "Add project");
    }

    public void saveProject(String name) {
        projectNameBox.clearAndType(name);
        saveProjectButton.click();
    }

    public boolean isProjectSaved(String projectName) {
        return projectSavedLabel.state().waitForDisplayed() && projectSavedLabel.getText().contains(projectName);
    }

}