diff --git a/components_derived/modal_change_password.py b/components_derived/modal_change_password.py index 4534dc6..22e27f9 100644 --- a/components_derived/modal_change_password.py +++ b/components_derived/modal_change_password.py @@ -47,7 +47,7 @@ class ChangePasswordModalWindow(ModalWindowComponent): "old password hidden icon") self.add_content_item("old_password_hidden_icon", old_password_hidden_icon) - loc = loc = page.locator(ModalWindowLocators.CHANDE_PASSWORD_WINDOW_NEW_PASSWORD) + loc = page.locator(ModalWindowLocators.CHANDE_PASSWORD_WINDOW_NEW_PASSWORD) new_password_input = TextInput(page, loc, "new_password_input") self.add_content_item("new_password_input", new_password_input) @@ -56,7 +56,7 @@ class ChangePasswordModalWindow(ModalWindowComponent): "new password hidden icon") self.add_content_item("new_password_hidden_icon", new_password_hidden_icon) - loc = loc = page.locator(ModalWindowLocators.CHANDE_PASSWORD_WINDOW_CHECK_PASSWORD) + loc = page.locator(ModalWindowLocators.CHANDE_PASSWORD_WINDOW_CHECK_PASSWORD) confirm_password_input = TextInput(page, loc, "confirm_password_input") self.add_content_item("confirm_password_input", confirm_password_input) @@ -71,10 +71,10 @@ class ChangePasswordModalWindow(ModalWindowComponent): self.add_content_item("input_form_error_message", input_form_error_message) # Добавление кнопок действий - locator_button_save = self.page.get_by_role("button", name="Сохранить") + locator_button_save = page.locator(ModalWindowLocators.CHANDE_PASSWORD_WINDOW_BUTTON_SAVE) self.add_button(locator_button_save, "save") - locator_button_cancel = self.page.get_by_role("button", name="Отменить") + locator_button_cancel = page.locator(ModalWindowLocators.CHANDE_PASSWORD_WINDOW_BUTTON_CANCEL) self.add_button(locator_button_cancel, "cancel") # Alert при успешном добавлении пользователя diff --git a/components_derived/user_card.py b/components_derived/user_card.py index 52e1965..dac585c 100644 --- a/components_derived/user_card.py +++ b/components_derived/user_card.py @@ -15,7 +15,6 @@ from components_derived.modal_change_password import ChangePasswordModalWindow logger = get_logger("USER_CARD") - class UserCard(BaseComponent): """Компонент карточка. @@ -36,37 +35,37 @@ class UserCard(BaseComponent): # Обновленные локаторы согласно новой структуре карточки self.current_user_name = Text( page, - card_locator.locator("xpath=/div/div[1]"), # Изменено с div[2] на div[1] + card_locator.locator("xpath=/div[@class='v-card__text']/div/div[1]"), # Изменено с div[2] на div[1] "current user name" ) self.current_user_role = Text( page, - card_locator.locator("xpath=/div/div[2]"), # Изменено с div[3] на div[2] + card_locator.locator("xpath=/div[@class='v-card__text']/div/div[2]"), # Изменено с div[3] на div[2] "current user role" ) self.login_time = Text( page, - card_locator.locator("xpath=/div/div[3]"), # Изменено с div[4] на div[3] + card_locator.locator("xpath=/div[@class='v-card__text']/div/div[3]"), # Изменено с div[4] на div[3] "login time" ) self.session_time = Text( page, - card_locator.locator("xpath=/div/div[4]"), # Изменено с div[5] на div[4] + card_locator.locator("xpath=/div[@class='v-card__text']/div/div[4]"), # Изменено с div[5] на div[4] "session time" # Исправлено имя с "current user name" на "session time" ) self.logout_button = Button( page, - page.get_by_role("button", name="Выйти"), + card_locator.locator(UserCardLocators.BUTTON_LOGOUT), "logout button" ) self.change_password_button = Button( page, - page.get_by_role("button", name="Изменить пароль"), + card_locator.locator(UserCardLocators.BUTTON_CHANGE_PASSWORD), "change password button" ) self.close_button = Button( page, - page.get_by_role("button", name="Закрыть"), + card_locator.locator(UserCardLocators.BUTTON_CLOSE), "close button" ) @@ -148,6 +147,6 @@ class UserCard(BaseComponent): Raises: AssertionError: Если карточка пользователя все еще открыта. """ - card_locator = self.page.locator(UserCardLocators.CARD_USER).locator("xpath=../..") + card_locator = self.page.locator(UserCardLocators.CARD_USER).locator("..") class_attr = card_locator.get_attribute('class') assert 'menuable__content__active' not in class_attr, "User card should be closed" diff --git a/locators/button_locators.py b/locators/button_locators.py index c2b6040..88145a6 100644 --- a/locators/button_locators.py +++ b/locators/button_locators.py @@ -13,6 +13,7 @@ class ButtonLocators: - Кнопка удаления сессии """ - BUTTON_LICENSE_UPDATE = "//div[@class='scrollarea__footer']//button" + BUTTON_LICENSE_UPDATE = "//button[@data-testid='LICENSE__btn__setLicense']" + TOOLTIP = "//div[contains(@class,'v-tooltip__content menuable__content__active')]" BUTTON_DELETE_SESSION = "button.v-btn--icon svg[fill='#4caf50']" diff --git a/locators/input_locators.py b/locators/input_locators.py index d2d9e15..845d53f 100644 --- a/locators/input_locators.py +++ b/locators/input_locators.py @@ -10,10 +10,6 @@ class InputLocators: Содержит XPath локаторы для: LICENSE_ID_UPDATE (str): поля ввода идентификатора лицензии в подвале - - - - """ - LICENSE_ID_UPDATE = "//div[@class='scrollarea__footer']//div[@class='v-input__control']//textarea" + LICENSE_ID_UPDATE = "//div[@class='v-input__control']//textarea[@data-testid='LICENSE__textarea__licenseKey']" diff --git a/locators/modal_window_locators.py b/locators/modal_window_locators.py index 76b4bb7..118b786 100644 --- a/locators/modal_window_locators.py +++ b/locators/modal_window_locators.py @@ -45,3 +45,6 @@ class ModalWindowLocators: CHANDE_PASSWORD_WINDOW_CURRENT_PASSWORD = "//input[@data-testid='CHANGE_PASS_CARD__text-field__current_password']" CHANDE_PASSWORD_WINDOW_NEW_PASSWORD = "//input[@data-testid='CHANGE_PASS_CARD__text-field__new_password']" CHANDE_PASSWORD_WINDOW_CHECK_PASSWORD = "//input[@data-testid='CHANGE_PASS_CARD__text-field__check_password']" + CHANDE_PASSWORD_WINDOW_BUTTON_SAVE = "//button[@data-testid='CHANGE_PASS_CARD__btn__save']" + CHANDE_PASSWORD_WINDOW_BUTTON_CANCEL = "//button[@data-testid='CHANGE_PASS_CARD__btn__cancel']" + diff --git a/locators/user_card_locators.py b/locators/user_card_locators.py index d393d47..0e68bc7 100644 --- a/locators/user_card_locators.py +++ b/locators/user_card_locators.py @@ -9,15 +9,13 @@ class UserCardLocators: Содержит XPath локаторы для: CARD_USER (str): карточки текущего пользователя. - DIALOG_USER_SETTINGS (str): окна просмотра сессионных данных пользователей. - HEADER_DIALOG_USER_SETTINGS (str): строки с заголовком окна и кнопкой закрытия. - TITLE_DIALOG_USER_SETTINGS (str): заголовка окна. - TABLE_WORK_AREA (str): таблицы с сессионными данными пользователей. + BUTTON_LOGOUT (str): кнопка выхода из приложения. + BUTTON_CHANGE_PASSWORD (str): кнопка открытия окна смены пароля. + BUTTON_CLOSE (str): кнопка закрытия окна текущего пользователя. """ - CARD_USER = "//div[@class='v-card__text']" - - DIALOG_USER_SETTINGS = "//div[@class='dialog-drag']" - HEADER_DIALOG_USER_SETTINGS = "xpath=/div[@class='dialog-header']" - TITLE_DIALOG_USER_SETTINGS = "xpath=/div[@class='dialog-header']/div[@class='title']" - TABLE_WORK_AREA = "//div[@class='dialog-body']//table" + # CARD_USER = "//div[@class='v-card__text']" + CARD_USER = "//div[@data-testid='BASELINE__card__user']" + BUTTON_LOGOUT = "//button[@data-testid='BASELINE__btn__user.menu__logout']" + BUTTON_CHANGE_PASSWORD = "//button[@data-testid='BASELINE__btn__user.menu__change_password']" + BUTTON_CLOSE = "//button[@data-testid='BASELINE__btn__user.menu__close']" diff --git a/pages/users_tab.py b/pages/users_tab.py index c00b8aa..560d0f8 100644 --- a/pages/users_tab.py +++ b/pages/users_tab.py @@ -32,17 +32,18 @@ class UsersTab(BasePage): super().__init__(page) - locator_button_1 = self.page.get_by_role("navigation").filter( - has_text=re.compile("Пользователи") - ).get_by_role("button").nth(0) - locator_button_2 = self.page.get_by_role("navigation").filter( - has_text=re.compile("Пользователи") - ).get_by_role("button").nth(1) - self.toolbar = ToolbarComponent(page, "Пользователи") - self.toolbar.add_tooltip_button(locator_button_1, "edit") - self.toolbar.add_tooltip_button(locator_button_1, "add_user") - self.toolbar.add_tooltip_button(locator_button_2, "close") + toolbar_button_edit = self.page.get_by_role("navigation").filter(has_text=re.compile("Пользователи")). \ + locator("//button[@data-testid='USERS__btn__edit']") + self.toolbar.add_tooltip_button(toolbar_button_edit, "edit") + + toolbar_button_add_user = self.page.get_by_role("navigation").filter(has_text=re.compile("Пользователи")). \ + locator("//button[@data-testid='USERS__btn__onAdd']") + self.toolbar.add_tooltip_button(toolbar_button_add_user, "add_user") + + toolbar_button_close = self.page.get_by_role("navigation").filter(has_text=re.compile("Пользователи")). \ + locator("//button[@data-testid='USERS__btn__close']") + self.toolbar.add_tooltip_button(toolbar_button_close, "close") self.users_table = TableComponent(page) self.modal_windows = {}