Актуализированы тесты управления пользователями
parent
a9b89b6608
commit
b7ca7194ae
4
.env
4
.env
|
|
@ -1,3 +1,3 @@
|
|||
ENV=test
|
||||
ENV=develop
|
||||
AUTH_LOGIN = admin
|
||||
AUTH_PASSWORD = admin
|
||||
AUTH_PASSWORD = admin123
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class AddADUserModalWindow(ModalWindowComponent):
|
|||
|
||||
# Локаторы элементов формы
|
||||
input_form_locator = page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA)
|
||||
text_field_locator = ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA
|
||||
text_field_locator = f"xpath={ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA}"
|
||||
label_locator = ModalWindowLocators.LABEL_INPUT_FORM_USER_DATA
|
||||
|
||||
# Настройка заголовка и кнопки закрытия тулбара
|
||||
|
|
@ -78,6 +78,7 @@ class AddADUserModalWindow(ModalWindowComponent):
|
|||
self.add_button(locator_button_search, "search")
|
||||
|
||||
# Поле Имя
|
||||
# loc = input_form_locator.locator("xpath=div[2]").locator(text_field_locator)
|
||||
loc = input_form_locator.locator("xpath=div[3]").locator(text_field_locator)
|
||||
name_input = TextInput(page, loc, "name_input")
|
||||
self.add_content_item("name_input", name_input)
|
||||
|
|
@ -182,7 +183,8 @@ class AddADUserModalWindow(ModalWindowComponent):
|
|||
"""Персчитывает локаторы полей формы ввода при добавлении/удалении дополнительного поля. """
|
||||
|
||||
input_form_locator = self.page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA)
|
||||
text_field_locator = ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA
|
||||
# text_field_locator = ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA
|
||||
text_field_locator = f"xpath={ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA}"
|
||||
|
||||
if expand:
|
||||
new_loc = input_form_locator.locator("xpath=div[4]").locator(text_field_locator)
|
||||
|
|
|
|||
|
|
@ -69,12 +69,8 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
|||
self.add_content_item("active_directory_checkbox_label", label_1)
|
||||
|
||||
# Поле Имя
|
||||
loc = (
|
||||
self.page.locator(input_form_locator)
|
||||
.locator("xpath=div[2]")
|
||||
.locator(text_field_locator)
|
||||
)
|
||||
name_input = TextInput(page, loc, "name_input")
|
||||
loc = f"{input_form_locator}/div[2]/{text_field_locator}"
|
||||
name_input = TextInput(page, self.page.locator(loc), "name_input")
|
||||
self.add_content_item("name_input", name_input)
|
||||
|
||||
# Чекбокс "Блокировка" - индекс 1
|
||||
|
|
@ -100,39 +96,23 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
|||
self.add_content_item("roles_list", DropdownList(page))
|
||||
|
||||
# Поле Пароль
|
||||
loc = (
|
||||
self.page.locator(input_form_locator)
|
||||
.locator("xpath=div[5]")
|
||||
.locator(text_field_locator)
|
||||
)
|
||||
password_input = TextInput(page, loc, "password_input")
|
||||
loc = f"{input_form_locator}/div[5]/{text_field_locator}"
|
||||
password_input = TextInput(page, self.page.locator(loc), "password_input")
|
||||
self.add_content_item("password_input", password_input)
|
||||
|
||||
# Поле Комментарий
|
||||
loc = (
|
||||
self.page.locator(input_form_locator)
|
||||
.locator("xpath=div[6]")
|
||||
.locator(text_field_locator)
|
||||
)
|
||||
commentary_input = TextInput(page, loc, "commentary_input")
|
||||
loc = f"{input_form_locator}/div[6]/{text_field_locator}"
|
||||
commentary_input = TextInput(page, self.page.locator(loc), "commentary_input")
|
||||
self.add_content_item("commentary_input", commentary_input)
|
||||
|
||||
# Поле E-mail
|
||||
loc = (
|
||||
self.page.locator(input_form_locator)
|
||||
.locator("xpath=div[7]")
|
||||
.locator(text_field_locator)
|
||||
)
|
||||
email_input = TextInput(page, loc, "email_input")
|
||||
loc = f"{input_form_locator}/div[7]/{text_field_locator}"
|
||||
email_input = TextInput(page, self.page.locator(loc), "email_input")
|
||||
self.add_content_item("email_input", email_input)
|
||||
|
||||
# Поле Номер для СМС
|
||||
loc = (
|
||||
self.page.locator(input_form_locator)
|
||||
.locator("xpath=div[8]")
|
||||
.locator(text_field_locator)
|
||||
)
|
||||
phone_input = TextInput(page, loc, "phone_input")
|
||||
loc = f"{input_form_locator}/div[8]/{text_field_locator}"
|
||||
phone_input = TextInput(page, self.page.locator(loc), "phone_input")
|
||||
self.add_content_item("phone_input", phone_input)
|
||||
|
||||
# Чекбокс "Подписка на Push-уведомления" - индекс 2
|
||||
|
|
@ -285,6 +265,9 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
|||
self.check_toolbar_button_visibility("close")
|
||||
self.check_toolbar_button_tooltip("close", "Закрыть")
|
||||
|
||||
input_fields = ["name_input", "password_input",
|
||||
"commentary_input", "email_input", "phone_input"]
|
||||
|
||||
for name in self.content_items:
|
||||
item = self.get_content_item(name)
|
||||
|
||||
|
|
@ -318,9 +301,15 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
|||
if role == "Пользователь":
|
||||
continue
|
||||
roles_list.check_item_with_text(role)
|
||||
elif name in input_fields:
|
||||
item.check_editable_input(
|
||||
f"Input field with name '{name}' should be editable"
|
||||
)
|
||||
elif name == "roles_list":
|
||||
continue
|
||||
else:
|
||||
print(f"check item: {name}")
|
||||
print(item)
|
||||
item.check_visibility(
|
||||
f"Modal window content item with name '{name}' is missing"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ class EditUserModalWindow(ModalWindowComponent):
|
|||
super().__init__(page)
|
||||
|
||||
# Локаторы элементов формы
|
||||
text_field_locator = ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA
|
||||
# text_field_locator = ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA
|
||||
text_field_locator = f"xpath={ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA}"
|
||||
input_form_locator = ModalWindowLocators.INPUT_FORM_USER_DATA
|
||||
label_locator = ModalWindowLocators.LABEL_INPUT_FORM_USER_DATA
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class BaseElement:
|
|||
"""Выполняет клик по элементу."""
|
||||
|
||||
logger.info(f"Clicking {self.type_of} '{self.name}'")
|
||||
self.locator.click()
|
||||
self.locator.click(force=True)
|
||||
|
||||
def get_text(self, index: int) -> str:
|
||||
"""Возвращает текст элемента по указанному индексу."""
|
||||
|
|
@ -78,7 +78,8 @@ class BaseElement:
|
|||
"""Проверяет видимость элемента на странице."""
|
||||
|
||||
logger.info(f"Check that {self.type_of} '{self.name}' is present")
|
||||
print(self.locator)
|
||||
# print(f"Check that {self.type_of} '{self.name}' is present")
|
||||
# print(self.locator)
|
||||
expect(self.locator).to_be_visible(visible=True, timeout=12000), msg
|
||||
|
||||
def is_present(self, timeout: int = 5000) -> bool:
|
||||
|
|
|
|||
|
|
@ -78,3 +78,16 @@ class TextInput(BaseElement):
|
|||
|
||||
logger.info(f'Checking that text input "{self.name}" is empty')
|
||||
expect(self.locator).to_be_empty(), msg
|
||||
|
||||
def check_editable_input(self, msg: str) -> None:
|
||||
"""Проверяет, что поле ввода редактируемое.
|
||||
|
||||
Args:
|
||||
msg (str): Сообщение об ошибке при неудачной проверке.
|
||||
|
||||
Raises:
|
||||
AssertionError: Если поле не пустое.
|
||||
"""
|
||||
|
||||
logger.info(f'Checking that text input "{self.name}" is editable')
|
||||
expect(self.locator).to_be_editable(), msg
|
||||
|
|
|
|||
|
|
@ -23,8 +23,9 @@ class ModalWindowLocators:
|
|||
MODAL_WINDOW_TITLE = f"{MODAL_WINDOW}//div[contains(@class, 'v-toolbar__title')]"
|
||||
MODAL_WINDOW_TEXT_FIELD_INPUT = f"{MODAL_WINDOW}//input"
|
||||
|
||||
INPUT_FORM_USER_DATA = "//form[@class='v-form']"
|
||||
TEXT_FIELD_INPUT_FORM_USER_DATA = "xpath=div[2]/div/div/div/div/input"
|
||||
INPUT_FORM_USER_DATA = f"{MODAL_WINDOW}//form[@class='v-form']"
|
||||
TEXT_FIELD_INPUT_FORM_USER_DATA = "div[2]/div/div/div/div/input"
|
||||
# TEXT_FIELD_INPUT_FORM_USER_DATA = "xpath=div[2]/div/div/div/div/input"
|
||||
MENU_INPUT_FORM_USER_DATA = "//div[contains(@class, 'menuable__content__active')]"
|
||||
LABEL_INPUT_FORM_USER_DATA = "//label[contains(@class,'v-label')]/span"
|
||||
|
||||
|
|
|
|||
|
|
@ -298,6 +298,8 @@ class UsersTab(BasePage):
|
|||
|
||||
self.toolbar.check_button_visibility("add_user")
|
||||
self.toolbar.click_button("add_user")
|
||||
self.page.wait_for_timeout(700)
|
||||
|
||||
self.add_modal_window("add_local_user", "")
|
||||
self.get_modal_window("add_local_user").check_by_window_title()
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ class TestLogin:
|
|||
lp = LoginPage(browser)
|
||||
lp.do_unsuccessful_login()
|
||||
|
||||
# @pytest.mark.develop
|
||||
def test_successful_login_and_logout(self, browser: Page) -> None:
|
||||
"""Проверяет успешный вход и выход из системы.
|
||||
|
||||
|
|
|
|||
|
|
@ -80,11 +80,14 @@ class TestUsersTabAddUser:
|
|||
"""
|
||||
|
||||
ut = UsersTab(browser)
|
||||
|
||||
ut.open_add_user_window()
|
||||
ut.check_add_user_window_content()
|
||||
ut.transform_to_add_AD_user_window()
|
||||
ut.check_add_AD_user_window_content()
|
||||
ut.close_add_AD_user_window()
|
||||
|
||||
# @pytest.mark.develop
|
||||
def test_add_user_window_close_buttons(self, browser: Page) -> None:
|
||||
"""Проверяет кнопки закрытия окна добавления.
|
||||
|
||||
|
|
@ -93,6 +96,8 @@ class TestUsersTabAddUser:
|
|||
"""
|
||||
|
||||
ut = UsersTab(browser)
|
||||
browser.wait_for_timeout(500)
|
||||
|
||||
ut.open_add_user_window()
|
||||
ut.close_add_user_window_by_toolbar_button()
|
||||
|
||||
|
|
@ -107,6 +112,7 @@ class TestUsersTabAddUser:
|
|||
ut.transform_to_add_AD_user_window()
|
||||
ut.close_add_AD_user_window()
|
||||
|
||||
# @pytest.mark.develop
|
||||
def test_add_local_user(self, browser: Page, cleanup_users: None) -> None:
|
||||
"""Проверяет добавление локального пользователя.
|
||||
|
||||
|
|
@ -118,6 +124,7 @@ class TestUsersTabAddUser:
|
|||
user_data: Dict[str, str] = {"name": "TestUser", "role": "Администратор", "password": "987654321abcd"}
|
||||
self._add_user(browser, user_data)
|
||||
|
||||
# @pytest.mark.develop
|
||||
def test_add_AD_user(self, browser: Page, cleanup_users: None) -> None:
|
||||
"""Проверяет добавление пользователя Active Directory.
|
||||
|
||||
|
|
@ -151,9 +158,8 @@ class TestUsersTabAddUser:
|
|||
if not user_exists:
|
||||
# Создаем пользователя впервые
|
||||
ut.open_add_user_window()
|
||||
success = ut.add_new_user(user_data)
|
||||
|
||||
if success:
|
||||
if ut.add_new_user(user_data):
|
||||
# Ждем обновления таблицы с использованием ожиданий Playwright
|
||||
browser.wait_for_timeout(2000)
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ class TestUsersTabEditUser:
|
|||
"""
|
||||
|
||||
ut = UsersTab(browser)
|
||||
browser.wait_for_timeout(500)
|
||||
|
||||
user_name, role = ut.open_edit_user_page_by_index(0)
|
||||
ut.check_edit_user_window_content(user_name, role)
|
||||
|
||||
|
|
@ -92,6 +94,8 @@ class TestUsersTabEditUser:
|
|||
"""
|
||||
|
||||
ut = UsersTab(browser)
|
||||
browser.wait_for_timeout(500)
|
||||
|
||||
user_name, _ = ut.open_edit_user_page_by_index(0)
|
||||
ut.close_edit_user_window_by_toolbar_button(user_name)
|
||||
user_name, _ = ut.open_edit_user_page_by_index(0)
|
||||
|
|
@ -109,6 +113,7 @@ class TestUsersTabEditUser:
|
|||
|
||||
mp = MainPage(browser)
|
||||
ut = UsersTab(browser)
|
||||
browser.wait_for_timeout(500)
|
||||
|
||||
# Проверяем, есть ли такой пользователь
|
||||
user_exists = ut.find_user_in_table(user_data["name"], user_data["role"]) != -1
|
||||
|
|
@ -149,6 +154,7 @@ class TestUsersTabEditUser:
|
|||
|
||||
mp = MainPage(browser)
|
||||
ut = UsersTab(browser)
|
||||
browser.wait_for_timeout(500)
|
||||
|
||||
ut.open_add_user_window()
|
||||
ut.add_new_user(user_data)
|
||||
|
|
@ -189,6 +195,7 @@ class TestUsersTabEditUser:
|
|||
|
||||
mp = MainPage(browser)
|
||||
ut = UsersTab(browser)
|
||||
browser.wait_for_timeout(500)
|
||||
|
||||
ut.open_add_user_window()
|
||||
ut.add_new_user(user_data)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ class TestUserCard:
|
|||
# Создание нового пользователя
|
||||
mp.click_main_navigation_panel_item("Настройки")
|
||||
mp.click_subpanel_item("Пользователи")
|
||||
browser.wait_for_timeout(500)
|
||||
|
||||
ut.open_add_user_window()
|
||||
ut.add_new_user(user_data)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue