package com.mavlushechka.a1qa.pages; import com.mavlushechka.a1qa.elements.Button; import com.mavlushechka.a1qa.elements.Label; import com.mavlushechka.a1qa.constants.Interest; import org.openqa.selenium.By; public class InterestsForm extends BaseForm { private final Button downloadImageButton = new Button(By.xpath("//button[contains(@class, 'avatar-and-interests__avatar-upload-button')]"), "Download image"); private final Button ballsInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_balls')]"), "Balls interest checkbox"); private final Button cablesInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_cables')]"), "Cables interest checkbox"); private final Button cinnamonInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_cinnamon')]"), "Cinnamon interest checkbox"); private final Button closetsInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_closets')]"), "Closets interest checkbox"); private final Button cottonInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_cotton')]"), "Cotton interest checkbox"); private final Button doughInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_dough')]"), "Dough interest checkbox"); private final Button drywallInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_drywall')]"), "Drywall interest checkbox"); private final Button enveloppesInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_enveloppes')]"), "Enveloppes interest checkbox"); private final Button faucetsInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_faucets')]"), "Faucets interest checkbox"); private final Button mulletsInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_mullets')]"), "Mullets interest checkbox"); private final Button poloInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_polo')]"), "Polo interest checkbox"); private final Button poniesInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_ponies')]"), "Ponies interest checkbox"); private final Button postitsInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_postits')]"), "Postits interest checkbox"); private final Button purpleInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_purple')]"), "Purple interest checkbox"); private final Button questionsInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_questions')]"), "Questions interest checkbox"); private final Button selectAllInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_selectall')]"), "Select all interest checkbox"); private final Button snailsAllInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_snails')]"), "Snails interest checkbox"); private final Button squaresInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_squares')]"), "Squares interest checkbox"); private final Button tiresInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_tires')]"), "Tires interest checkbox"); private final Button unselectAllInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_unselectall')]"), "Unselect all interest checkbox"); private final Button windowsInterestButton = new Button(By.xpath("//label[contains(@class, 'checkbox__label') and contains(@for, 'interest_windows')]"), "Windows interest checkbox"); public InterestsForm() { super(new Label(By.xpath("//*[contains(@class, 'avatar-and-interests-page')]"), "Interests"), "Interests"); } public void select(Interest interest) { switch (interest) { case BALLS -> ballsInterestButton.click(); case CABLES -> cablesInterestButton.click(); case CINNAMON -> cinnamonInterestButton.click(); case CLOSETS -> closetsInterestButton.click(); case COTTON -> cottonInterestButton.click(); case DOUGH -> doughInterestButton.click(); case DRYWALL -> drywallInterestButton.click(); case ENVELOPPES -> enveloppesInterestButton.click(); case FAUCETS -> faucetsInterestButton.click(); case MULLETS -> mulletsInterestButton.click(); case POLO -> poloInterestButton.click(); case PONIES -> poniesInterestButton.click(); case POSTITS -> postitsInterestButton.click(); case PURPLE -> purpleInterestButton.click(); case QUESTIONS -> questionsInterestButton.click(); case SELECTALL -> selectAllInterestButton.click(); case SNAILS -> snailsAllInterestButton.click(); case SQUARES -> squaresInterestButton.click(); case TIRES -> tiresInterestButton.click(); case UNSELECTALL -> unselectAllInterestButton.click(); case WINDOWS -> windowsInterestButton.click(); } } public void clickDownloadImageButton() { downloadImageButton.click(); } }