AlexTrue1916

Untitled

Sep 3rd, 2021 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 9.47 KB | None | 0 0
  1. package pages;
  2.  
  3. import io.qameta.allure.Step;
  4. import org.openqa.selenium.Keys;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.support.FindBy;
  7. import pages.edg.EdgLandingPage;
  8. import pages.landing.LandingsPage;
  9. import pages.payments.ChildPaymentsPage;
  10. import pages.personal.PersonalAreaLoginPage;
  11. import pages.personal.PersonalAreaPage;
  12. import pages.personal.documents.personnal.AllEventsPage;
  13. import pages.portal.criminal.CriminalCertificateStartPage;
  14. import pages.portal.kindergarten.BookKindergartenStartPage;
  15. import pages.portal.passport.ForeignPassportStartPage;
  16. import pages.portal.registration.RegistrationStartPage;
  17. import pages.services.AboutRegistrationСitizenPlaceStayPage;
  18. import pages.services.ServicesCategoryPage;
  19. import pages.services.ServicesMarriageRegistrationPage;
  20. import pages.services.ServicesPassportRFPage;
  21. import pages.services.ServicesDrugsCertificationPage;
  22.  
  23. public class HomePage extends BasePage {
  24.  
  25.     @FindBy(xpath = "//a[@class='lk-enter']")
  26.     private WebElement personalAreaButton;
  27.  
  28.     @FindBy(xpath = "//a[text()='Все уведомления']")
  29.     private WebElement allNotificationButton;
  30.  
  31.     @FindBy(xpath = "//div[contains(text(),'портал Госуслуг')]")
  32.     private WebElement navigateToPortalButton;
  33.  
  34.     @FindBy(xpath = "//a[@class='main-app-logo']")
  35.     private WebElement mainLogo;
  36.  
  37.     @FindBy(xpath = "//p[@class='plain-text ng-scope']//a[contains(text(),'Запись ребенка в детский сад')]")
  38.     private WebElement pushChildrenIntoTheKinderGardenLink;
  39.  
  40.     @FindBy(xpath = "//a[contains(.,'Запись в детский сад')]")
  41.     private WebElement recordIntoTheKinderGardenLink;
  42.  
  43.     @FindBy(xpath = "//div[contains(@class, 'main-navigation__item')]/a[text()='Услуги']")
  44.     private WebElement servicesLink;
  45.  
  46.     @FindBy(xpath = "//div[@class='search-ico']")
  47.     private WebElement searchIcon;
  48.  
  49.     @FindBy(xpath = "//input[@placeholder='что вы ищете?']")
  50.     private WebElement searchForm;
  51.  
  52.     @FindBy(xpath = "//div[text()='Регистрация гражданина по месту жительства']")
  53.     private WebElement registrationAtResidenceResultLabel;
  54.  
  55.     @FindBy(xpath = "//div[text()='Регистрация гражданина по месту пребывания']")
  56.     private WebElement RegistrationPlaceStay;
  57.  
  58.     @FindBy(xpath = "//div[text()='Справка об отсутствии судимости']")
  59.     private WebElement criminalCertificateResultLabel;
  60.  
  61.     @FindBy(xpath = "//div[@class='icon services' and text()='Регистрация брака']")
  62.     private WebElement marriageRegistrationResultLabel;
  63.  
  64.     @FindBy(xpath = "//div[text()='Выдача или замена паспорта гражданина РФ']")
  65.     private WebElement obtainingPassportRFLabel;
  66.  
  67.     @FindBy(xpath = "//div[text()='Заграничный паспорт']")
  68.     private WebElement internationalPassportLabel;
  69.  
  70.     @FindBy(xpath = "//div[text()='Справка об отсутствии наказания за употребление наркотиков']")
  71.     private WebElement drugsCertificationPunishmentLabel;
  72.  
  73.     @FindBy(xpath = "//*[contains(.,'Укажите ваше местоположение')]")
  74.     private WebElement userLocationPopup;
  75.  
  76.     @FindBy(xpath = "//span[@class='search-label']")
  77.     private WebElement searchButton;
  78.  
  79.     public HomePage() {
  80.         waitForPageVisible();
  81.     }
  82.  
  83.     private WebElement divLabel(String text) {
  84.         return xpathElement("//div[text()='%s']", text);
  85.     }
  86.  
  87.     @Step("Переход к услуге записи в детский сад")
  88.     public PersonalAreaPage navigateToChildrenIntoTheKinderGardenForm() {
  89.         clickElement(pushChildrenIntoTheKinderGardenLink);
  90.         clickElement(recordIntoTheKinderGardenLink);
  91.         return new PersonalAreaPage();
  92.     }
  93.  
  94.     @Step("Вернуть состояние лого 'Госуслуги' на главной странице портала")
  95.     public boolean isMainLogoPresent() {
  96.         return isElementExist(mainLogo);
  97.     }
  98.  
  99.     @Step("Вернуться на портал госулуг")
  100.     public PortalMainPage navigateToPortal() {
  101.         clickElement(navigateToPortalButton);
  102.         return new PortalMainPage("/");
  103.     }
  104.  
  105.     @Step("Кликнуть на 'Услуги'")
  106.     public ServicesCategoryPage clickToServices() {
  107.         clickElement(servicesLink);
  108.         return new ServicesCategoryPage();
  109.     }
  110.  
  111.     @Step("Нажать на 'Личный кабинет' и перейти на PersonalAreaLoginPage")
  112.     public PersonalAreaLoginPage navigateToPersonalAreaLoginPage() {
  113.         closeUserLocationPopup();
  114.         clickElement(personalAreaButton);
  115.         return new PersonalAreaLoginPage();
  116.     }
  117.  
  118.     @Step("Кликнуть на кнопку 'Все уведомления'")
  119.     public AllEventsPage clickOnAllNotificationButton() {
  120.         clickElement(allNotificationButton);
  121.         return new AllEventsPage();
  122.     }
  123.  
  124.     @Step("Перейти на Страницу входа в ЛК(PersonalAreaLoginPage)")
  125.     public PersonalAreaLoginPage openPersonalAreaLoginPage() {
  126.         return new PersonalAreaLoginPage();
  127.     }
  128.  
  129.     @Step("Перейти на основную страницу портала и закрыть попап")
  130.     public PersonalAreaPage navigateToPersonalAreaPageAndClosePopup() {
  131.         closeUserLocationPopup();
  132.         return new PersonalAreaPage();
  133.     }
  134.  
  135.     @Step("Перейти на основную страницу портала ")
  136.     public PersonalAreaPage navigateToPersonalAreaPage() {
  137.         return new PersonalAreaPage();
  138.     }
  139.  
  140.     private void closeUserLocationPopup() {
  141.         if (isElementExist(userLocationPopup)) {
  142.             userLocationPopup.sendKeys(Keys.ESCAPE);
  143.         }
  144.     }
  145.  
  146.     @Step("Перейти на Страницу лендинга(ElectionLandingPage)")
  147.     public EdgLandingPage openEdgLandingPage() {
  148.         return new EdgLandingPage();
  149.     }
  150.  
  151.     @Step("Перейти на Страницу лендинга 'Пособие 2020'(ChildPaymentsPage)")
  152.     public ChildPaymentsPage openChildPaymentsPage() {
  153.         return new ChildPaymentsPage();
  154.     }
  155.  
  156.     @Step("Перейти на Страницу лендингов(LandingsPage)")
  157.     public LandingsPage openLandingsPage() {
  158.         if (isElementExist(userLocationPopup)) {
  159.             userLocationPopup.sendKeys(Keys.ESCAPE);
  160.         }
  161.         return new LandingsPage();
  162.     }
  163.  
  164.     @Step("Перейти на страницу 'Запись ребёнка в детский сад' (BookKindergartenStartPage)")
  165.     public BookKindergartenStartPage navigateToBookKindergartenStartPage() {
  166.         return new BookKindergartenStartPage();
  167.     }
  168.  
  169.     @Step("Клик на иконку поиска")
  170.     public HomePage clickToSearchIcon() {
  171.         clickElement(searchIcon);
  172.         return this;
  173.     }
  174.  
  175.     @Step("Заполнить поисковую строку {0}")
  176.     public HomePage setSearchQuery(String query) {
  177.         searchForm.clear();
  178.         searchForm.sendKeys(query);
  179.         return this;
  180.     }
  181.  
  182.     @Step("Кликаем в поисковой выдачи на: 'Регистрация гражданина по месту жительства'")
  183.     public RegistrationStartPage clickSearchResultRegistrationResidence() {
  184.         clickElement(registrationAtResidenceResultLabel);
  185.         return new RegistrationStartPage();
  186.     }
  187.  
  188.     @Step("Кликаем в поисковой выдачи на: 'Регистрация по месту пребывания'")
  189.     public AboutRegistrationСitizenPlaceStayPage clickSearchResultRegistrationPlaceStay() {
  190.         clickElement(RegistrationPlaceStay);
  191.         return new AboutRegistrationСitizenPlaceStayPage();
  192.     }
  193.  
  194.     @Step("Кликаем в поисковой выдачи на: 'Справка об отсутствии судимости'")
  195.     public CriminalCertificateStartPage clickSearchResultCriminalCertificate() {
  196.         clickElement(criminalCertificateResultLabel);
  197.         return new CriminalCertificateStartPage();
  198.     }
  199.  
  200.     @Step("Кликаем в поисковой выдачи на: 'Регистрация брака'")
  201.     public ServicesMarriageRegistrationPage clickSearchResultMarrigeRegistration() {
  202.         clickElement(marriageRegistrationResultLabel);
  203.         return new ServicesMarriageRegistrationPage();
  204.     }
  205.  
  206.     @Step("Кликаем в поисковой выдачи на: 'Выдача или замена паспорта гражданина РФ'")
  207.     public ServicesPassportRFPage clickSerchResultObtainingPassportRF() {
  208.         clickElement(obtainingPassportRFLabel);
  209.         return new ServicesPassportRFPage();
  210.     }
  211.  
  212.     @Step("Кликам в поисковой выдачи на: 'Заграничный паспорт'")
  213.     public ForeignPassportStartPage clickSerchResultatInternationalPassport() {
  214.         clickElement(internationalPassportLabel);
  215.         return new ForeignPassportStartPage();
  216.     }
  217.  
  218.     @Step("Кликам в поисковой выдачи на: 'Справка об отсутствии наказания за употребление наркотиков'")
  219.     public ServicesDrugsCertificationPage clickSerchResultatDrugsCertificationPunishment() {
  220.         clickElement(drugsCertificationPunishmentLabel);
  221.         return new ServicesDrugsCertificationPage();
  222.     }
  223. }
  224.  
Add Comment
Please, Sign In to add comment