diff options
Diffstat (limited to 'src/main/java/com/mavlushechka/a1qa/pages')
4 files changed, 125 insertions, 0 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/pages/FirstCardForm.java b/src/main/java/com/mavlushechka/a1qa/pages/FirstCardForm.java new file mode 100644 index 0000000..df5608b --- /dev/null +++ b/src/main/java/com/mavlushechka/a1qa/pages/FirstCardForm.java @@ -0,0 +1,42 @@ +package com.mavlushechka.a1qa.pages; + +import com.mavlushechka.a1qa.elements.Button; +import com.mavlushechka.a1qa.elements.Field; +import com.mavlushechka.a1qa.elements.Label; +import com.mavlushechka.a1qa.models.User; +import org.openqa.selenium.By; + +public class FirstCardForm extends BaseForm { + + private final Field passwordField = new Field(By.xpath("//*[contains(@class, 'login-form__field-row') and not(contains(@class, 'align'))]//input"), "Password"); + private final Field emailField = new Field(By.xpath("//*[contains(@class, 'login-form__field-row')]//*[contains(@class, 'align__cell')]//input"), "Email"); + private final Field emailServerField = new Field(By.xpath("//*[contains(@class, 'login-form__field-row')]//*[contains(@class, 'align__cell')]//input[contains(@placeholder, 'Domain')]"), "Domain"); + private final Button dropdownOpenerButton = new Button(By.xpath("//*[contains(@class, 'dropdown__opener')]"), "Dropdown opener"); + private final Button termsAndConditionsCheckbox = new Button(By.xpath("//*[contains(@class, 'checkbox')]"), "Terms and conditions checkbox"); + private final Button nextButton = new Button(By.xpath("//*[contains(@class, 'button-container__secondary')]//a[contains(@class, 'button--secondary') and not(contains(@class, 'u-right'))]"), "Next"); + + private final String dropdownListItemXpath = "//*[contains(@class, 'dropdown__list')]//*[contains(text(), '%s')]"; + + + public FirstCardForm() { + super(new Label(By.xpath("//*[contains(@class, 'login-form')]"), "First card"), "First card"); + } + + public void performAuthorization(User user) { + clearFields(); + passwordField.sendKeys(user.password(), true); + emailField.sendKeys(user.email().username()); + emailServerField.sendKeys(user.email().server()); + dropdownOpenerButton.click(); + new Button(By.xpath(dropdownListItemXpath.formatted(user.email().domain())), "Domain").click(); + termsAndConditionsCheckbox.click(); + nextButton.click(); + } + + private void clearFields() { + passwordField.clear(); + emailField.clear(); + emailServerField.clear(); + } + +} diff --git a/src/main/java/com/mavlushechka/a1qa/pages/GamePage.java b/src/main/java/com/mavlushechka/a1qa/pages/GamePage.java new file mode 100644 index 0000000..740f634 --- /dev/null +++ b/src/main/java/com/mavlushechka/a1qa/pages/GamePage.java @@ -0,0 +1,38 @@ +package com.mavlushechka.a1qa.pages; + +import com.mavlushechka.a1qa.elements.Label; +import com.mavlushechka.a1qa.models.Interest; +import com.mavlushechka.a1qa.models.User; +import org.openqa.selenium.By; + +public class GamePage extends BaseForm { + + private final FirstCardForm firstCardForm = new FirstCardForm(); + private final SecondCardForm secondCardForm = new SecondCardForm(); + + + public GamePage() { + super(new Label(By.xpath("//*[@id='app']//*[contains(@class, 'game')]"), "Game view"), "Game"); + } + + public boolean isFirstCardFormOpened() { + return firstCardForm.isOpened(); + } + + public void performAuthorization(User user) { + firstCardForm.performAuthorization(user); + } + + public boolean isSecondCardOpened() { + return secondCardForm.isOpened(); + } + + public void select(Interest interest) { + secondCardForm.select(interest); + } + + public void clickDownloadImageButton() { + secondCardForm.clickDownloadImageButton(); + } + +} diff --git a/src/main/java/com/mavlushechka/a1qa/pages/HomePage.java b/src/main/java/com/mavlushechka/a1qa/pages/HomePage.java new file mode 100644 index 0000000..ee52ba9 --- /dev/null +++ b/src/main/java/com/mavlushechka/a1qa/pages/HomePage.java @@ -0,0 +1,20 @@ +package com.mavlushechka.a1qa.pages; + +import com.mavlushechka.a1qa.elements.Button; +import com.mavlushechka.a1qa.elements.Label; +import org.openqa.selenium.By; + +public class HomePage extends BaseForm { + + private final Button nextPageButton = new Button(By.xpath("//a[contains(@class, 'start__link')]"), "Next page"); + + + public HomePage() { + super(new Label(By.xpath("//*[@id='app']//*[contains(@class, 'start')]"), "App container"), "Home"); + } + + public void clickNextPageButton() { + nextPageButton.click(); + } + +} diff --git a/src/main/java/com/mavlushechka/a1qa/pages/SecondCardForm.java b/src/main/java/com/mavlushechka/a1qa/pages/SecondCardForm.java new file mode 100644 index 0000000..ea381cb --- /dev/null +++ b/src/main/java/com/mavlushechka/a1qa/pages/SecondCardForm.java @@ -0,0 +1,25 @@ +package com.mavlushechka.a1qa.pages; + +import com.mavlushechka.a1qa.elements.Button; +import com.mavlushechka.a1qa.elements.Label; +import com.mavlushechka.a1qa.models.Interest; +import org.openqa.selenium.By; + +public class SecondCardForm extends BaseForm { + + private final Button downloadImageButton = new Button(By.xpath("//button[contains(@class, 'avatar-and-interests__avatar-upload-button')]"), "Download image"); + + + public SecondCardForm() { + super(new Label(By.xpath("//*[contains(@class, 'avatar-and-interests-page')]"), "Second card"), "Second card"); + } + + public void select(Interest interest) { + interest.checkbox.click(); + } + + public void clickDownloadImageButton() { + downloadImageButton.click(); + } + +} |