Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix locators for all page objects #2016

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/test/playwright/PO/AddChallengePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ class AddChallengePage extends BasePage {
constructor(page) {
super(page);
this.backToChallengesButton = page.locator('a.back-btn[href="/dev/admin/challenges"]');
this.viewChallengeButton = page.locator('div.add-form a:nth-child(2)');
this.viewChallengeButton = page.locator('a[href^="/dev/challenges/"] button');
this.challengeSequenceNumberField = page.locator('input#sortNumber');
this.challengeNameField = page.locator('input#name');
this.challengeTitleField = page.locator('input#title');
this.challengeDescriptionField = page.locator(".ql-editor");
this.challengePhotoInput = page.locator('input[type="file"]');
this.saveButton = page.locator('button.flooded-button[type="submit"]');

this.challengeAddedSuccessMessage = this.page.locator("div.ant-message-success");
this.challengeAddedSuccessMessage = this.page.locator('div.ant-message-success');

}

Expand Down
64 changes: 32 additions & 32 deletions src/test/playwright/PO/AddClubPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@ class AddClubPage extends BasePage {
constructor(page) {
super(page);
//Step 1 - Основна Інформація
this.goBackButton = this.page.getByRole("button", { name: ADD_CLUB_PAGE.stepBack });
this.nextStepButton = this.page.getByRole("button", { name: ADD_CLUB_PAGE.nextStep });
this.clubNameField = this.page.locator("input#basic_name");
this.childAgeFrom = this.page.locator("input#basic_ageFrom");
this.childAgeTo = this.page.locator("input#basic_ageTo");
this.relatedCenterDropdown = this.page.locator("input#basic_centerId");
this.goBackButton = this.page.getByRole('button', { name: ADD_CLUB_PAGE.stepBack });
this.nextStepButton = this.page.getByRole('button', { name: ADD_CLUB_PAGE.nextStep });
this.clubNameField = this.page.locator('input#basic_name');
this.childAgeFrom = this.page.locator('input#basic_ageFrom');
this.childAgeTo = this.page.locator('input#basic_ageTo');
this.relatedCenterDropdown = this.page.locator('input#basic_centerId');
//Error messages
this.nameFieldErrorMessage = this.page.locator("div#basic_name_help");
this.categoryFieldErrorMessage = this.page.locator("div#basic_categories_help");
this.ageFromFieldErrorMessage = this.page.locator("div#basic_ageFrom_help");
this.ageToFieldErrorMessage = this.page.locator("div#basic_ageTo_help");
this.nameFieldErrorMessage = this.page.locator('div#basic_name_help');
this.categoryFieldErrorMessage = this.page.locator('div#basic_categories_help');
this.ageFromFieldErrorMessage = this.page.locator('div#basic_ageFrom_help');
this.ageToFieldErrorMessage = this.page.locator('div#basic_ageTo_help');

//Step 2 - Контакти/Локація
this.addLocationButton = this.page.locator("span.add-club-location");
this.locationNameField = this.page.locator("input#name");
this.locationCityDropdown = this.page.locator("input#cityName");
this.locationDistrictDropdown = this.page.locator("input#districtName");
this.locationStationDropdown = this.page.locator("input#stationName");
this.locationAddressField = this.page.locator("input#address");
this.locationCoordinatesField = this.page.locator("input#coordinates");
this.locationPhoneNumberField = this.page.locator("input#phone");
this.addLocationButton = this.page.locator('span.add-club-location');
this.locationNameField = this.page.locator('input#name');
this.locationCityDropdown = this.page.locator('input#cityName');
this.locationDistrictDropdown = this.page.locator('input#districtName');
this.locationStationDropdown = this.page.locator('input#stationName');
this.locationAddressField = this.page.locator('input#address');
this.locationCoordinatesField = this.page.locator('input#coordinates');
this.locationPhoneNumberField = this.page.locator('input#phone');
this.locationAddButton = this.page.locator('div.add-club-locations button[type="submit"]');

this.locationNameInfoSign = this.page.locator('input#name + span svg');
this.locationPhoneInfoSign = this.page.locator('input#phone + span svg');

this.locationCloseButton = this.page.locator('button[aria-label="Close"]').nth(1);
this.locationCloseButton = this.page.locator('div.ant-modal-content').filter({hasText: ADD_CLUB_PAGE.geographicCoordinates}).locator('button[aria-label="Close"]');

this.locationsList = this.page.locator('div.add-club-location-list ul.ant-list-items');

Expand All @@ -51,27 +51,27 @@ class AddClubPage extends BasePage {
this.clubSkypeField = this.page.locator('input#basic_contactSkype')
this.clubWebPageField = this.page.locator('input#basic_contactSite')
//Error messages
this.locationNameFieldErrorMessage = this.page.locator("div#name_help");
this.locationCityErrorMessage = this.page.locator("div#cityName_help");
this.locationAddressFieldErrorMessage = this.page.locator("div#address_help");
this.locationCoordinatesFieldErrorMessage = this.page.locator("div#coordinates_help");
this.locationPhoneFieldErrorMessage = this.page.locator("div#phone_help");
this.locationNameFieldErrorMessage = this.page.locator('div#name_help');
this.locationCityErrorMessage = this.page.locator('div#cityName_help');
this.locationAddressFieldErrorMessage = this.page.locator('div#address_help');
this.locationCoordinatesFieldErrorMessage = this.page.locator('div#coordinates_help');
this.locationPhoneFieldErrorMessage = this.page.locator('div#phone_help');

this.clubPhoneFieldErrorMessage = this.page.locator("div#basic_contactТелефон_help");
this.clubEmailFieldErrorMessage = this.page.locator("div#basic_contactПошта_help");
this.clubPhoneFieldErrorMessage = this.page.locator('div#basic_contactТелефон_help');
this.clubEmailFieldErrorMessage = this.page.locator('div#basic_contactПошта_help');

//Step 3 - Опис
this.clubIsAutomaticallyOnlineMessage = this.page.locator('div.ant-message-notice-content').filter({ hasText: ADD_CLUB_PAGE.noLocationClubOnlineMessage });;
this.clubIsAutomaticallyOnlineMessage = this.page.locator('div.ant-message-notice-content').filter({ hasText: ADD_CLUB_PAGE.noLocationClubOnlineMessage });
this.addLogoInput = this.page.locator('input#basic_urlLogo')
this.addCoverInput = this.page.locator('input#basic_urlBackground')
this.addImagesInput = this.page.locator('div.ant-upload-list-picture-card input');
this.descriptionTextArea = this.page.locator("textarea[placeholder='Додайте опис гуртка']");
this.completeButton = this.page.getByRole("button", { name: "Завершити" });
this.descriptionTextArea = this.page.locator(`textarea[placeholder='${ADD_CLUB_PAGE.addClubDescription}']`);
this.completeButton = this.page.getByRole('button', { name: ADD_CLUB_PAGE.complete });

this.clubCreatedSuccessMessage = this.page.locator("div.ant-message-success");
this.clubAlreadyExistMessage = this.page.locator("div.ant-message-notice-content").filter({ hasText: ADD_CLUB_PAGE.clubAlreadyExistMessage});;
this.clubCreatedSuccessMessage = this.page.locator('div.ant-message-success');
this.clubAlreadyExistMessage = this.page.locator('div.ant-message-notice-content').filter({ hasText: ADD_CLUB_PAGE.clubAlreadyExistMessage});
//Error messages
this.clubDescriptionErrorMessage = this.page.locator("div#basic_description_help");
this.clubDescriptionErrorMessage = this.page.locator('div#basic_description_help');

}

Expand Down
15 changes: 8 additions & 7 deletions src/test/playwright/PO/AddTaskPage.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { challengesAdminUrl, ADD_CHALLENGE_ADMIN_URL } from "../constants/api.constants";
import { CHALLENGES_ADMIN_URL, ADD_CHALLENGE_ADMIN_URL } from "../constants/api.constants";
import { ADD_TASK_PAGE } from "../constants/locatorsText.constants";
import { IMAGES_PATH } from "../constants/general.constants";
import BasePage from "./BasePage";

class AddTaskPage extends BasePage {
constructor(page) {
super(page);
this.backToTasksButton = page.locator('a.back-btn[href="/dev/admin/tasks"]');
this.viewTaskButton = page.locator('div.add-form a:nth-child(2)');
this.viewTaskButton = page.locator('a[href^="/dev/challenges/task"] button');
this.taskDateStartField = page.locator('input#startDate');
this.taskPhotoInput = page.locator('input[type="file"]');
this.taskNameField = page.locator('input#name');
this.taskTitleField = page.locator("div.ant-form-item:nth-child(4) .ql-editor");
this.taskDescriptionField = page.locator("div.ant-form-item:nth-child(5) .ql-editor");
this.taskChallengeField = page.locator("input#challengeId");
this.taskTitleField = page.locator('div.ant-form-item').filter({ hasText: ADD_TASK_PAGE.title }).locator('.ql-editor');
this.taskDescriptionField =page.locator('div.ant-form-item').filter({ hasText: ADD_TASK_PAGE.description }).locator('.ql-editor');
this.taskChallengeField = page.locator('input#challengeId');
this.saveButton = page.locator('button.flooded-button[type="submit"]');

this.taskAddedSuccessMessage = this.page.locator("div.ant-message-success");
this.taskAddedSuccessMessage = this.page.locator('div.ant-message-success');

}

Expand All @@ -25,7 +26,7 @@ class AddTaskPage extends BasePage {

async openChallengesPage() {
await this.backToChallengesButton.click();
await this.verifyUrl(challengesAdminUrl)
await this.verifyUrl(CHALLENGES_ADMIN_URL)
}

async selectDate(date){
Expand Down
4 changes: 2 additions & 2 deletions src/test/playwright/PO/BasePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { expect } from "@playwright/test";
class BasePage {
constructor(page) {
this.page = page;
this.navBarCityDropdown = page.locator("header > div.right-side-menu div.city");
this.navBarCityDropdownList = page.locator("body > div:last-child ul");
this.navBarCityDropdown = page.locator('header > div.right-side-menu div.city');
this.navBarCityDropdownList = page.locator('body > div:last-child ul');
this.paginationNextPageButton = page.locator('ul > li[title="Next Page"]');
this.paginationFirstPage = page.locator('li[title="1"]');
}
Expand Down
28 changes: 14 additions & 14 deletions src/test/playwright/PO/ChallengeInfoPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ import { CHALLENGE_INFO_PAGE } from "../constants/locatorsText.constants";
class ChallengeInfoPage extends BasePage {
constructor(page) {
super(page);
this.viewChallengeButton = page.getByRole("button", { name: CHALLENGE_INFO_PAGE.viewChallenge });
this.viewChallengeTitle = page.locator("span.title");
this.slickCard = page.locator("div.slick-slide");
this.slickCardsNames = page.locator("div.slick-slide div.name");
this.slickDots = page.locator("ul.slick-dots li");
this.slickRightArrow = page.locator("span.arrows-next svg");

this.challengePageTitle = page.locator("h1.ant-typography");
this.challengeSortNumber = page.locator("input#sortNumber");
this.challengeStatus = page.locator("button#isActive");
this.challengeName = page.locator("input#name");
this.challengeTitle = page.locator("input#title");
this.challengeDescription = page.locator("div.ql-editor");
this.viewChallengeButton = page.getByRole('button', { name: CHALLENGE_INFO_PAGE.viewChallenge });
this.viewChallengeTitle = page.locator('span.title');
this.slickCard = page.locator('div.slick-slide');
this.slickCardsNames = page.locator('div.slick-slide div.name');
this.slickDots = page.locator('ul.slick-dots li');
this.slickRightArrow = page.locator('span.arrows-next svg');

this.challengePageTitle = page.locator('h1.ant-typography');
this.challengeSortNumber = page.locator('input#sortNumber');
this.challengeStatus = page.locator('button#isActive');
this.challengeName = page.locator('input#name');
this.challengeTitle = page.locator('input#title');
this.challengeDescription = page.locator('div.ql-editor');
this.saveButton = page.locator('button.flooded-button[type="submit"]');

this.tasksTableCells = page.locator("td[class='ant-table-cell']");
this.tasksTableCells = page.locator('td[class="ant-table-cell"]');
}

async openViewChallenge() {
Expand Down
33 changes: 17 additions & 16 deletions src/test/playwright/PO/ChallengesPage.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import { CHALLENGES_ADMIN_URL, ADD_CHALLENGE_ADMIN_URL, TASKS_ADMIN_URL } from "../constants/api.constants";
import { CHALLENGES_PAGE } from "../constants/locatorsText.constants";
import BasePage from "./BasePage";

class ChallengesPage extends BasePage {
constructor(page) {
super(page);
this.challengesPageTitle = page.getByRole("heading", { name: "Челенджі" });
this.addChallengeButton = page.locator("button.add-btn");
this.openTasksButton = page.locator("a.back-btn button");
this.addTaskButton = page.locator("a[href='/dev/admin/addTask']");
this.allChallengesSequenceNumbers = page.locator("tbody td:nth-child(2)");
this.firstChallenge = page.locator("tr:first-child td.ant-table-cell:first-child");
this.editChallengeButtons = page.locator("span.table-action:nth-child(1)");
this.editConfirmButton = page.locator("span.table-action").filter({ hasText: "Зберегти" });
this.editCancelButton = page.locator("span.table-action").filter({ hasText: "Відмінити" });
this.challengesPageTitle = page.getByRole('heading', { name: CHALLENGES_PAGE.challenges });
this.addChallengeButton = page.locator('button.add-btn');
this.openTasksButton = page.locator('a.back-btn button');
this.addTaskButton = page.locator('a[href="/dev/admin/addTask"]');
this.allChallengesSequenceNumbers = page.locator(`td.ant-table-cell:nth-child(${CHALLENGES_PAGE.sequenceNumberTableColumn})`);
this.firstChallenge = page.locator('tr:first-child td.ant-table-cell:first-child');
this.editChallengeButtons = page.locator('span.table-action').filter({ hasText: CHALLENGES_PAGE.edit });
this.editConfirmButton = page.locator('span.table-action').filter({ hasText: CHALLENGES_PAGE.save });
this.editCancelButton = page.locator('span.table-action').filter({ hasText: CHALLENGES_PAGE.cancel });

this.deleteChallengeButtons = page.locator("span.table-action:nth-child(2)");
this.deleteChallengeButtons = page.locator('span.table-action').filter({hasText: CHALLENGES_PAGE.delete });;
//insecure locator below (each time 'delete' button was clicked, it created a new instance). No unique locator available
this.popUpYes = page.locator("button.popConfirm-ok-button");
this.popUpNo = page.locator("popConfirm-cancel-button");
this.popUpYes = page.locator('button.popConfirm-ok-button');
this.popUpNo = page.locator('popConfirm-cancel-button');

this.challengeSequenceNumberField = page.locator("input#sortNumber");
this.challengeNameField = page.locator("input#name");
this.challengeTitleField = page.locator("input#title");
this.challengeSequenceNumberField = page.locator('input#sortNumber');
this.challengeNameField = page.locator('input#name');
this.challengeTitleField = page.locator('input#title');

this.actionSuccessMessage = page.locator("div.ant-message-success");
this.actionSuccessMessage = page.locator('div.ant-message-success');
}

async gotoChallengesPage() {
Expand Down
13 changes: 7 additions & 6 deletions src/test/playwright/PO/ClubInfoPage.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

import BasePage from "./BasePage";
import { CLUB_INFO_PAGE } from "../constants/locatorsText.constants"

class ClubInfoPage extends BasePage {
constructor(page) {
super(page);
this.clubPageTitle = page.locator("div.name-box");
this.clubPageTags = page.locator("span.tag span.name");
this.clubPageAddress = page.locator("div.address");
this.clubPageDescription = page.locator("div.content");
this.clubPageContactData = page.locator("div.social-media div.links").nth(0);//.locator('span.contact-name');
this.clubPageDevelopmentCenter = page.locator("div.center span.name");
this.clubPageTitle = page.locator('div.name-box');
this.clubPageTags = page.locator('span.tag span.name');
this.clubPageAddress = page.locator('div.address');
this.clubPageDescription = page.locator('div.content');
this.clubPageContactData = page.locator('div.social-media').filter({hasText: CLUB_INFO_PAGE.contactClub}).locator('div.links');
this.clubPageDevelopmentCenter = page.locator('div.center span.name');
}
}

Expand Down
19 changes: 10 additions & 9 deletions src/test/playwright/PO/ClubsPage.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { expect} from "@playwright/test";
import {CLUBS_URL} from "../constants/api.constants";
import {CLUBS_PAGE} from "../constants/locatorsText.constants";
import BasePage from "./BasePage";

class ClubsPage extends BasePage {
constructor(page) {
super(page);
this.clubsPageTitle = page.locator(".city-name");
this.clubsPageTitle = page.locator('.city-name');
this.searchField = page.locator('div.search-container input[type="search"]');
this.searchButton = page.locator('span[aria-label="search"]');
this.cards = page.locator("div.ant-card");
this.clubsNames = page.locator("div.title");
this.clubsCategories = page.locator("div.club-tags-box span.name");
this.clubsDescriptions = page.locator("p.description");
this.clubsANDcategories = page.locator("span.and");
this.clubDetailsCategories = page.locator("div.tags.categories span.name");
this.cards = page.locator('div.ant-card');
this.clubsNames = page.locator('div.title');
this.clubsCategories = page.locator('div.club-tags-box span.name');
this.clubsDescriptions = page.locator('p.description');
this.clubsANDcategories = page.locator('span.and');
this.clubDetailsCategories = page.locator('div.tags.categories span.name');
this.clubDetailsCloseButton = page.locator('button[aria-label="Close"]');
this.paginationNextPageButton = page.locator('ul > li[title="Next Page"]');
this.paginationFirstPageButton = page.locator('ul > li[title="1"]');
this.advancedSearchButton = page.locator('span[title="Розширений пошук"]');
this.firstCardTitle = page.locator("div.content-clubs-list > div:first-child div.name");
this.advancedSearchButton = page.locator(`span[title='${CLUBS_PAGE.extendedSearch}']`);
this.firstCardTitle = page.locator('div.content-clubs-list > div:first-child div.name');

this.noResultsMessage = page.locator('div.clubs-not-found');
}
Expand Down
Loading
Loading