Compare commits
1 Commits
main
...
new_add_ed
| Author | SHA1 | Date |
|---|---|---|
|
|
6805cd2bbc |
2
.env
2
.env
|
|
@ -1,3 +1,3 @@
|
||||||
ENV=test
|
ENV=develop
|
||||||
AUTH_LOGIN = admin
|
AUTH_LOGIN = admin
|
||||||
AUTH_PASSWORD = enodemon-admin
|
AUTH_PASSWORD = enodemon-admin
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,11 @@ class DropdownList(BaseComponent):
|
||||||
|
|
||||||
loc = self.get_locator(locator)
|
loc = self.get_locator(locator)
|
||||||
texts = loc.all_inner_texts()
|
texts = loc.all_inner_texts()
|
||||||
return texts[0].splitlines()
|
if len(texts) == 1 and texts[0].find("\n") != -1:
|
||||||
|
names = list(texts[0].splitlines())
|
||||||
|
else:
|
||||||
|
names = list(texts)
|
||||||
|
return names
|
||||||
|
|
||||||
def get_selected_combobox_value(self, combobox_locator: str | Locator,
|
def get_selected_combobox_value(self, combobox_locator: str | Locator,
|
||||||
value_locator: str | Locator = None) -> str:
|
value_locator: str | Locator = None) -> str:
|
||||||
|
|
|
||||||
|
|
@ -1,471 +0,0 @@
|
||||||
"""Модуль modal_add_user содержит класс для работы с модальным окном добавления пользователя.
|
|
||||||
|
|
||||||
Класс AddUserModalWindow наследует базовый функционал ModalWindowComponent
|
|
||||||
и реализует специфичные методы для работы с формами добавления пользователей.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import re
|
|
||||||
from playwright.sync_api import Page
|
|
||||||
from tools.logger import get_logger
|
|
||||||
from locators.modal_window_locators import ModalWindowLocators
|
|
||||||
from elements.text_input_element import TextInput
|
|
||||||
from elements.text_element import Text
|
|
||||||
from elements.checkbox_element import Checkbox
|
|
||||||
from data.roles_dict import roles_dict
|
|
||||||
from components.modal_window_component import ModalWindowComponent
|
|
||||||
from components.dropdown_list_component import DropdownList
|
|
||||||
from components.confirm_component import ConfirmComponent
|
|
||||||
|
|
||||||
|
|
||||||
logger = get_logger("ADD_USER_FROM_ACTIVE_DIRECTORY_MODAL_WINDOW")
|
|
||||||
|
|
||||||
|
|
||||||
class AddADUserModalWindow(ModalWindowComponent):
|
|
||||||
"""Модальное окно добавления нового пользователя.
|
|
||||||
|
|
||||||
Наследует ModalWindowComponent и добавляет элементы формы:
|
|
||||||
- Поля ввода (имя, пароль, email и др.)
|
|
||||||
- Чекбоксы (Active Directory, Push-уведомления)
|
|
||||||
- Выпадающие списки групп, пользователей AD, ролей
|
|
||||||
- Кнопки действий
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, page: Page):
|
|
||||||
"""Инициализирует элементы формы добавления пользователя."""
|
|
||||||
|
|
||||||
super().__init__(page)
|
|
||||||
|
|
||||||
# Локаторы элементов формы
|
|
||||||
input_form_locator = page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA)
|
|
||||||
text_field_locator = f"xpath={ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA}"
|
|
||||||
label_locator = ModalWindowLocators.LABEL_INPUT_FORM_USER_DATA
|
|
||||||
|
|
||||||
# Настройка заголовка и кнопки закрытия тулбара
|
|
||||||
self.window_title = "Добавить нового пользователя"
|
|
||||||
locator_button_toolbar_close = self.page.get_by_role("navigation").filter(
|
|
||||||
has_text=re.compile(self.window_title)
|
|
||||||
).get_by_role("button")
|
|
||||||
|
|
||||||
self.add_toolbar_title(self.window_title)
|
|
||||||
self.add_toolbar_button(locator_button_toolbar_close, "close")
|
|
||||||
|
|
||||||
# Добавление элементов формы
|
|
||||||
checkbox_1 = Checkbox(
|
|
||||||
page,
|
|
||||||
input_form_locator.get_by_role("checkbox").nth(0),
|
|
||||||
"active_directory"
|
|
||||||
)
|
|
||||||
self.add_content_item("active_directory_checkbox", checkbox_1)
|
|
||||||
|
|
||||||
label_1 = Text(
|
|
||||||
page,
|
|
||||||
self.page.locator(label_locator).nth(0),
|
|
||||||
"active_directory_checkbox_label"
|
|
||||||
)
|
|
||||||
self.add_content_item("active_directory_checkbox_label", label_1)
|
|
||||||
|
|
||||||
# Начальный набор полей формы
|
|
||||||
# Поле Группа
|
|
||||||
group_loc = input_form_locator.get_by_role("combobox").nth(0)
|
|
||||||
group_input = TextInput(page, group_loc, "group_input")
|
|
||||||
self.add_content_item("group_input", group_input)
|
|
||||||
self.add_content_item(
|
|
||||||
"group_list",
|
|
||||||
DropdownList(page)
|
|
||||||
)
|
|
||||||
|
|
||||||
locator_button_search = self.page.get_by_role("button", name="Поиск")
|
|
||||||
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)
|
|
||||||
|
|
||||||
# Чекбокс "Блокировка" - индекс 1
|
|
||||||
checkbox_2 = Checkbox(
|
|
||||||
page,
|
|
||||||
input_form_locator.get_by_role("checkbox").nth(1),
|
|
||||||
"blocking"
|
|
||||||
)
|
|
||||||
self.add_content_item("blocking_checkbox", checkbox_2)
|
|
||||||
|
|
||||||
# Метка "Блокировка" - индекс 1
|
|
||||||
label_2 = Text(
|
|
||||||
page,
|
|
||||||
self.page.locator(label_locator).nth(1),
|
|
||||||
"blocking_checkbox_label"
|
|
||||||
)
|
|
||||||
self.add_content_item("blocking_checkbox_label", label_2)
|
|
||||||
|
|
||||||
# Поле Роль
|
|
||||||
role_loc = input_form_locator.get_by_role("combobox").nth(1)
|
|
||||||
role_input = TextInput(page, role_loc, "role_input")
|
|
||||||
self.add_content_item("role_input", role_input)
|
|
||||||
self.add_content_item(
|
|
||||||
"roles_list",
|
|
||||||
DropdownList(page)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Поле Комментарий
|
|
||||||
loc = input_form_locator.locator("xpath=div[7]").locator(text_field_locator)
|
|
||||||
commentary_input = TextInput(page, loc, "commentary_input")
|
|
||||||
self.add_content_item("commentary_input", commentary_input)
|
|
||||||
|
|
||||||
# Поле E-mail
|
|
||||||
loc = input_form_locator.locator("xpath=div[8]").locator(text_field_locator)
|
|
||||||
email_input = TextInput(page, loc, "email_input")
|
|
||||||
self.add_content_item("email_input", email_input)
|
|
||||||
|
|
||||||
# Поле Номер для СМС
|
|
||||||
loc = input_form_locator.locator("xpath=div[9]").locator(text_field_locator)
|
|
||||||
phone_input = TextInput(page, loc, "phone_input")
|
|
||||||
self.add_content_item("phone_input", phone_input)
|
|
||||||
|
|
||||||
# Чекбокс "Подписка на Push-уведомления" - индекс 2
|
|
||||||
checkbox_3 = Checkbox(
|
|
||||||
page,
|
|
||||||
input_form_locator.get_by_role("checkbox").nth(2),
|
|
||||||
"push_notification"
|
|
||||||
)
|
|
||||||
self.add_content_item("push_notification_checkbox", checkbox_3)
|
|
||||||
|
|
||||||
# Метка "Подписка на Push-уведомления" - индекс 2
|
|
||||||
label_3 = Text(
|
|
||||||
page,
|
|
||||||
self.page.locator(label_locator).nth(2),
|
|
||||||
"push_notification_checkbox_label"
|
|
||||||
)
|
|
||||||
self.add_content_item("push_notification_checkbox_label", label_3)
|
|
||||||
|
|
||||||
# Добавление кнопок действий
|
|
||||||
locator_button_add = self.page.get_by_role("button", name="Добавить")
|
|
||||||
self.add_button(locator_button_add, "add")
|
|
||||||
|
|
||||||
locator_button_close = self.page.get_by_role("button", name="Закрыть")
|
|
||||||
self.add_button(locator_button_close, "close")
|
|
||||||
|
|
||||||
self.new_user_confirm = ConfirmComponent(page, " Отмена ", " Добавить ")
|
|
||||||
|
|
||||||
# Действия:
|
|
||||||
def check_active_directory_checkbox(self):
|
|
||||||
"""Включает чек-бокс Active Directory. """
|
|
||||||
|
|
||||||
self.get_content_item("active_directory_checkbox").check(force=True)
|
|
||||||
|
|
||||||
def uncheck_active_directory_checkbox(self):
|
|
||||||
"""Выключает чек-бокс Active Directory. """
|
|
||||||
|
|
||||||
self.get_content_item("active_directory_checkbox").uncheck(force=True)
|
|
||||||
|
|
||||||
def check_blocking_checkbox(self):
|
|
||||||
"""Включает чек-бокс Блокировка."""
|
|
||||||
|
|
||||||
self.get_content_item("blocking_checkbox").check(force=True)
|
|
||||||
|
|
||||||
def uncheck_blocking_checkbox(self):
|
|
||||||
"""Выключает чек-бокс Блокировка."""
|
|
||||||
|
|
||||||
self.get_content_item("blocking_checkbox").uncheck(force=True)
|
|
||||||
|
|
||||||
def check_push_notification_checkbox(self):
|
|
||||||
"""Включает чек-бокс Push-уведомления."""
|
|
||||||
|
|
||||||
self.get_content_item("push_notification_checkbox").check(force=True)
|
|
||||||
|
|
||||||
def uncheck_push_notification_checkbox(self):
|
|
||||||
"""Выключает чек-бокс Push-уведомления."""
|
|
||||||
|
|
||||||
self.get_content_item("push_notification_checkbox").uncheck(force=True)
|
|
||||||
|
|
||||||
def update_input_form_fields(self, expand):
|
|
||||||
"""Персчитывает локаторы полей формы ввода при добавлении/удалении дополнительного поля. """
|
|
||||||
|
|
||||||
input_form_locator = self.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}"
|
|
||||||
|
|
||||||
if expand:
|
|
||||||
new_loc = input_form_locator.locator("xpath=div[4]").locator(text_field_locator)
|
|
||||||
self.get_content_item("name_input").update_locator(new_loc)
|
|
||||||
|
|
||||||
new_loc = input_form_locator.locator("xpath=div[8]").locator(text_field_locator)
|
|
||||||
self.get_content_item("commentary_input").update_locator(new_loc)
|
|
||||||
|
|
||||||
new_loc = input_form_locator.locator("xpath=div[9]").locator(text_field_locator)
|
|
||||||
self.get_content_item("email_input").update_locator(new_loc)
|
|
||||||
|
|
||||||
new_loc = input_form_locator.locator("xpath=div[10]").locator(text_field_locator)
|
|
||||||
self.get_content_item("phone_input").update_locator(new_loc)
|
|
||||||
|
|
||||||
role_loc = input_form_locator.get_by_role("combobox").nth(2)
|
|
||||||
self.get_content_item("role_input").update_locator(role_loc)
|
|
||||||
else:
|
|
||||||
new_loc = input_form_locator.locator("xpath=div[3]").locator(text_field_locator)
|
|
||||||
self.get_content_item("name_input").update_locator(new_loc)
|
|
||||||
|
|
||||||
new_loc = input_form_locator.locator("xpath=div[7]").locator(text_field_locator)
|
|
||||||
self.get_content_item("commentary_input").update_locator(new_loc)
|
|
||||||
|
|
||||||
new_loc = input_form_locator.locator("xpath=div[8]").locator(text_field_locator)
|
|
||||||
self.get_content_item("email_input").update_locator(new_loc)
|
|
||||||
|
|
||||||
new_loc = input_form_locator.locator("xpath=div[9]").locator(text_field_locator)
|
|
||||||
self.get_content_item("phone_input").update_locator(new_loc)
|
|
||||||
|
|
||||||
role_loc = input_form_locator.get_by_role("combobox").nth(1)
|
|
||||||
self.get_content_item("role_input").update_locator(role_loc)
|
|
||||||
|
|
||||||
def new_user(self, user_data):
|
|
||||||
"""Заполняет форму и добавляет нового пользователя.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
user_data (dict): Данные пользователя (имя, роль, пароль и др.)
|
|
||||||
"""
|
|
||||||
|
|
||||||
menu_locator = self.page.locator(ModalWindowLocators.MENU_INPUT_FORM_USER_DATA)
|
|
||||||
input_form_locator = self.page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA)
|
|
||||||
|
|
||||||
# Поле "Группа" - выбор из списка
|
|
||||||
group_name = user_data.get("group")
|
|
||||||
if group_name is None:
|
|
||||||
assert False, "Value of 'group' is missing"
|
|
||||||
|
|
||||||
# Поле "Пользователи AD" - выбор из списка
|
|
||||||
name_AD = user_data.get("name_AD")
|
|
||||||
if name_AD is None:
|
|
||||||
assert False, "Value of 'name_AD' is missing"
|
|
||||||
|
|
||||||
# Поле "Имя" - если определено (не None) вводим вручную
|
|
||||||
name = user_data.get("name")
|
|
||||||
|
|
||||||
# Поле "Роль" - выбор из списка
|
|
||||||
role = user_data.get("role")
|
|
||||||
if role is None:
|
|
||||||
assert False, "Value of 'role' is missing"
|
|
||||||
|
|
||||||
# Поиск и выбор заданной группы из списка существующих
|
|
||||||
group_field = self.get_content_item("group_input")
|
|
||||||
group_field.click()
|
|
||||||
|
|
||||||
group_list = self.get_content_item("group_list")
|
|
||||||
group_list.scroll_until_end(menu_locator)
|
|
||||||
group_names = group_list.get_item_names(menu_locator)
|
|
||||||
if group_name not in group_names:
|
|
||||||
assert False, f"Required group name {group_name} is missing"
|
|
||||||
|
|
||||||
group_list.check_item_with_text(group_name)
|
|
||||||
group_list.click_item_with_text(group_name)
|
|
||||||
|
|
||||||
# Нажатие кнопки "Поиск"
|
|
||||||
search_button = self.get_button_by_name("search")
|
|
||||||
search_button.click()
|
|
||||||
|
|
||||||
count = input_form_locator.get_by_role("combobox").count()
|
|
||||||
if count == 2:
|
|
||||||
assert False, f"Selected group {group_name} is empty. Use another group."
|
|
||||||
|
|
||||||
# Если в группе есть пользователи, открывается новое поле, персчет локаторов
|
|
||||||
self.update_input_form_fields(expand=True)
|
|
||||||
|
|
||||||
# Поиск и выбор заданного пользователя AD из списка существующих
|
|
||||||
user_AD_loc = input_form_locator.get_by_role("combobox").nth(1)
|
|
||||||
user_AD_input = TextInput(self.page, user_AD_loc, "user_AD_input")
|
|
||||||
self.add_content_item("user_AD_input", user_AD_input)
|
|
||||||
self.add_content_item(
|
|
||||||
"user_AD_list",
|
|
||||||
DropdownList(self.page)
|
|
||||||
)
|
|
||||||
|
|
||||||
user_AD_input.click()
|
|
||||||
user_AD_list = self.get_content_item("user_AD_list")
|
|
||||||
user_AD_list.scroll_until_end(menu_locator)
|
|
||||||
user_AD_names = group_list.get_item_names(menu_locator)
|
|
||||||
if name_AD not in user_AD_names:
|
|
||||||
assert False, f"Required user name {name_AD} is missing"
|
|
||||||
|
|
||||||
user_AD_list.check_item_with_text(name_AD)
|
|
||||||
user_AD_list.click_item_with_text(name_AD)
|
|
||||||
|
|
||||||
# Заполнение поля "Имя" (ручной ввод) если задано
|
|
||||||
if name:
|
|
||||||
name_field = self.get_content_item("name_input")
|
|
||||||
name_field.input_value(name)
|
|
||||||
|
|
||||||
# Поиск и выбор заданной роли из списка существующих
|
|
||||||
role_field = self.get_content_item("role_input")
|
|
||||||
role_field.click()
|
|
||||||
|
|
||||||
roles_list = self.get_content_item("roles_list")
|
|
||||||
roles_list.check_item_with_text(user_data["role"])
|
|
||||||
roles_list.click_item_with_text(user_data["role"])
|
|
||||||
|
|
||||||
if user_data.get("commentary"):
|
|
||||||
input_field = self.get_content_item("commentary_input")
|
|
||||||
input_field.input_value(user_data["commentary"])
|
|
||||||
|
|
||||||
if user_data.get("email"):
|
|
||||||
input_field = self.get_content_item("email_input")
|
|
||||||
input_field.input_value(user_data["email"])
|
|
||||||
|
|
||||||
if user_data.get("phone_number"):
|
|
||||||
input_field = self.get_content_item("phone_input")
|
|
||||||
input_field.input_value(user_data["phone_number"])
|
|
||||||
|
|
||||||
if user_data.get("blocking_checked"):
|
|
||||||
checkbox = self.get_content_item("blocking_checkbox")
|
|
||||||
if user_data["blocking_checked"]:
|
|
||||||
checkbox.check()
|
|
||||||
else:
|
|
||||||
checkbox.uncheck()
|
|
||||||
|
|
||||||
if user_data.get("push_notification_checked"):
|
|
||||||
checkbox = self.get_content_item("push_notification_checkbox")
|
|
||||||
if user_data["push_notification_checked"]:
|
|
||||||
checkbox.check()
|
|
||||||
else:
|
|
||||||
checkbox.uncheck()
|
|
||||||
|
|
||||||
# Отправка формы
|
|
||||||
add_button = self.get_button_by_name("add")
|
|
||||||
add_button.click()
|
|
||||||
|
|
||||||
# Подтверждение действия
|
|
||||||
title = "Добавить нового пользователя"
|
|
||||||
self.new_user_confirm.check_title(
|
|
||||||
title,
|
|
||||||
f"Confirmation dialog window with title '{title}' is missing"
|
|
||||||
)
|
|
||||||
self.new_user_confirm.click_allow_button()
|
|
||||||
|
|
||||||
def close_window(self):
|
|
||||||
"""Закрывает модальное окно через кнопку 'Закрыть'."""
|
|
||||||
|
|
||||||
close_button = self.get_button_by_name("close")
|
|
||||||
close_button.click()
|
|
||||||
|
|
||||||
def close_window_by_toolbar_button(self):
|
|
||||||
"""Закрывает модальное окно через кнопку в тулбаре."""
|
|
||||||
|
|
||||||
self.click_toolbar_close_button()
|
|
||||||
|
|
||||||
# Проверки:
|
|
||||||
def check_content(self):
|
|
||||||
"""Проверяет наличие и корректность всех элементов формы."""
|
|
||||||
|
|
||||||
input_form_locator = self.page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA)
|
|
||||||
menu_locator = self.page.locator(ModalWindowLocators.MENU_INPUT_FORM_USER_DATA)
|
|
||||||
|
|
||||||
self.check_by_window_title()
|
|
||||||
|
|
||||||
is_checked = self.get_content_item("active_directory_checkbox").is_checked()
|
|
||||||
if not is_checked:
|
|
||||||
assert False, \
|
|
||||||
"The checkbox 'Active Directory'should be checked for the add user from Active Directory window"
|
|
||||||
|
|
||||||
self.check_toolbar_button_visibility("close")
|
|
||||||
self.check_toolbar_button_tooltip("close", "Закрыть")
|
|
||||||
|
|
||||||
no_op_names = ["roles_list", "group_list"]
|
|
||||||
|
|
||||||
for name in self.content_items.keys():
|
|
||||||
item = self.get_content_item(name)
|
|
||||||
|
|
||||||
if name == "active_directory_checkbox_label":
|
|
||||||
item.check_have_text(
|
|
||||||
"Active Directory",
|
|
||||||
"Label 'Active Directory' is missing"
|
|
||||||
)
|
|
||||||
elif name == "blocking_checkbox_label":
|
|
||||||
item.check_have_text(
|
|
||||||
"Блокировка",
|
|
||||||
"Label 'Блокировка' is missing"
|
|
||||||
)
|
|
||||||
elif name == "push_notification_checkbox_label":
|
|
||||||
item.check_have_text(
|
|
||||||
"Подписка на Push-уведомления",
|
|
||||||
"Label 'Подписка на Push-уведомления' is missing"
|
|
||||||
)
|
|
||||||
elif name == "group_input":
|
|
||||||
item.click()
|
|
||||||
group_list = self.get_content_item("group_list")
|
|
||||||
group_list.check_visibility(menu_locator,
|
|
||||||
"Groups list is missing")
|
|
||||||
|
|
||||||
is_scrollable_vertically = group_list.check_vertical_scrolling(menu_locator)
|
|
||||||
assert is_scrollable_vertically, "Groups list should be scrollable_vertically"
|
|
||||||
self.page.keyboard.press("Escape")
|
|
||||||
elif name == "role_input":
|
|
||||||
item.click()
|
|
||||||
roles_list = self.get_content_item("roles_list")
|
|
||||||
roles_list.check_visibility(menu_locator,
|
|
||||||
"Roles list is missing")
|
|
||||||
|
|
||||||
is_scrollable_vertically = roles_list.check_vertical_scrolling(menu_locator)
|
|
||||||
assert not is_scrollable_vertically, \
|
|
||||||
"Roles list should not be scrollable_vertically"
|
|
||||||
|
|
||||||
for role in roles_dict.values():
|
|
||||||
# временно, пока есть несоответствие со списком ролей в вкладке Сессии
|
|
||||||
if role == "Пользователь":
|
|
||||||
continue
|
|
||||||
roles_list.check_item_with_text(role)
|
|
||||||
self.page.keyboard.press("Escape")
|
|
||||||
elif name in no_op_names:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
print(f"check item: {name}")
|
|
||||||
item.check_visibility(
|
|
||||||
f"Modal window content item with name '{name}' is missing"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Дополнительная проверка состояния чекбоксов
|
|
||||||
blocking_checkbox = self.get_content_item("blocking_checkbox")
|
|
||||||
is_blocking_checked = blocking_checkbox.is_checked()
|
|
||||||
assert not is_blocking_checked, (
|
|
||||||
"Checkbox 'Блокировка' should not be checked by default"
|
|
||||||
)
|
|
||||||
|
|
||||||
push_checkbox = self.get_content_item("push_notification_checkbox")
|
|
||||||
is_push_checked = push_checkbox.is_checked()
|
|
||||||
assert not is_push_checked, (
|
|
||||||
"Checkbox 'Подписка на Push-уведомления' should not be checked by default"
|
|
||||||
)
|
|
||||||
|
|
||||||
self.check_button_visibility("search")
|
|
||||||
self.check_button_visibility("add")
|
|
||||||
self.check_button_visibility("close")
|
|
||||||
|
|
||||||
search_button = self.get_button_by_name("search")
|
|
||||||
search_button.click()
|
|
||||||
|
|
||||||
# Проверка что поле "Пользователи AD" появилось после поиска
|
|
||||||
user_AD_loc = input_form_locator.get_by_role("combobox").nth(1)
|
|
||||||
user_AD_input = TextInput(self.page, user_AD_loc, "user_AD_input")
|
|
||||||
self.add_content_item("user_AD_input", user_AD_input)
|
|
||||||
self.add_content_item(
|
|
||||||
"user_AD_list",
|
|
||||||
DropdownList(self.page)
|
|
||||||
)
|
|
||||||
|
|
||||||
user_AD_input.click()
|
|
||||||
user_AD_list = self.get_content_item("user_AD_list")
|
|
||||||
user_AD_list.check_visibility(menu_locator,
|
|
||||||
"Users AD list is missing")
|
|
||||||
is_scrollable_vertically = user_AD_list.check_vertical_scrolling(menu_locator)
|
|
||||||
assert is_scrollable_vertically, "Users AD list should be scrollable_vertically"
|
|
||||||
self.page.keyboard.press("Escape")
|
|
||||||
|
|
||||||
self.update_input_form_fields(expand=True)
|
|
||||||
|
|
||||||
self.get_content_item("name_input").check_visibility(
|
|
||||||
"Modal window content item with name 'name_input' is missing")
|
|
||||||
self.get_content_item("role_input").check_visibility(
|
|
||||||
"Modal window content item with name 'role_input' is missing")
|
|
||||||
self.get_content_item("commentary_input").check_visibility(
|
|
||||||
"Modal window content item with name 'commentary_input' is missing")
|
|
||||||
self.get_content_item("email_input").check_visibility(
|
|
||||||
"Modal window content item with name 'email_input' is missing")
|
|
||||||
self.get_content_item("phone_input").check_visibility(
|
|
||||||
"Modal window content item with name 'phone_input' is missing")
|
|
||||||
|
|
@ -12,21 +12,19 @@ from locators.modal_window_locators import ModalWindowLocators
|
||||||
from elements.text_input_element import TextInput
|
from elements.text_input_element import TextInput
|
||||||
from elements.text_element import Text
|
from elements.text_element import Text
|
||||||
from elements.checkbox_element import Checkbox
|
from elements.checkbox_element import Checkbox
|
||||||
from data.roles_dict import roles_dict
|
|
||||||
from components.modal_window_component import ModalWindowComponent
|
from components.modal_window_component import ModalWindowComponent
|
||||||
from components.dropdown_list_component import DropdownList
|
from components.dropdown_list_component import DropdownList
|
||||||
from components.confirm_component import ConfirmComponent
|
from components.confirm_component import ConfirmComponent
|
||||||
|
from components_derived.selection_bar_component import SelectionBarComponent
|
||||||
|
|
||||||
|
logger = get_logger("ADD_USER_MODAL_WINDOW")
|
||||||
|
|
||||||
logger = get_logger("ADD_LOCAL_USER_MODAL_WINDOW")
|
class AddUserModalWindow(ModalWindowComponent):
|
||||||
|
|
||||||
|
|
||||||
class AddLocalUserModalWindow(ModalWindowComponent):
|
|
||||||
"""Модальное окно добавления нового пользователя.
|
"""Модальное окно добавления нового пользователя.
|
||||||
|
|
||||||
Наследует ModalWindowComponent и добавляет элементы формы:
|
Наследует ModalWindowComponent и добавляет элементы формы:
|
||||||
- Поля ввода (имя, пароль, email и др.)
|
- Поля ввода (имя, пароль, email и др.)
|
||||||
- Чекбоксы (Active Directory, Блокировка, Push-уведомления)
|
- Чекбоксы (Блокировка, Push-уведомления)
|
||||||
- Выпадающий список ролей
|
- Выпадающий список ролей
|
||||||
- Кнопки действий
|
- Кнопки действий
|
||||||
"""
|
"""
|
||||||
|
|
@ -37,7 +35,7 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
super().__init__(page)
|
super().__init__(page)
|
||||||
|
|
||||||
# Локаторы элементов формы
|
# Локаторы элементов формы
|
||||||
text_field_locator = ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA
|
text_field_locator = f"//{ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA}"
|
||||||
input_form_locator = ModalWindowLocators.INPUT_FORM_USER_DATA
|
input_form_locator = ModalWindowLocators.INPUT_FORM_USER_DATA
|
||||||
|
|
||||||
# Настройка заголовка и кнопки закрытия тулбара
|
# Настройка заголовка и кнопки закрытия тулбара
|
||||||
|
|
@ -51,11 +49,17 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
self.add_toolbar_title(self.window_title)
|
self.add_toolbar_title(self.window_title)
|
||||||
self.add_toolbar_button(locator_button_toolbar_close, "close")
|
self.add_toolbar_button(locator_button_toolbar_close, "close")
|
||||||
|
|
||||||
# Поле Имя
|
elements_locators = self._get_fields_locators(page)
|
||||||
loc = f"{input_form_locator}/div[1]/{text_field_locator}"
|
|
||||||
name_input = TextInput(page, self.page.locator(loc), "name_input")
|
|
||||||
self.add_content_item("name_input", name_input)
|
|
||||||
|
|
||||||
|
# Поле Тип авторизации
|
||||||
|
loc = elements_locators.get("Тип авторизации")
|
||||||
|
auth_type_selector = SelectionBarComponent(page, loc.get_by_role("combobox"))
|
||||||
|
self.add_content_item("auth_type_selector", auth_type_selector)
|
||||||
|
|
||||||
|
# Поле Имя
|
||||||
|
loc = elements_locators.get("Имя").locator(text_field_locator)
|
||||||
|
name_input = TextInput(page, loc, "name_input")
|
||||||
|
self.add_content_item("name_input", name_input)
|
||||||
|
|
||||||
# Метка "Блокировка"
|
# Метка "Блокировка"
|
||||||
label_blocking_locator = self.page.locator(input_form_locator). \
|
label_blocking_locator = self.page.locator(input_form_locator). \
|
||||||
|
|
@ -77,29 +81,29 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
self.add_content_item("blocking_checkbox", checkbox_blocking)
|
self.add_content_item("blocking_checkbox", checkbox_blocking)
|
||||||
|
|
||||||
# Поле Роль
|
# Поле Роль
|
||||||
role_loc = self.page.locator(input_form_locator).get_by_role("combobox").nth(0)
|
role_loc = elements_locators.get("Роль").get_by_role("combobox")
|
||||||
role_input = TextInput(page, role_loc, "role_input")
|
role_input = TextInput(page, role_loc, "role_input")
|
||||||
self.add_content_item("role_input", role_input)
|
self.add_content_item("role_input", role_input)
|
||||||
self.add_content_item("roles_list", DropdownList(page))
|
self.add_content_item("roles_list", DropdownList(page))
|
||||||
|
|
||||||
# Поле Пароль
|
# Поле Пароль
|
||||||
loc = f"{input_form_locator}/div[4]/{text_field_locator}"
|
loc = elements_locators.get("Пароль").locator(text_field_locator)
|
||||||
password_input = TextInput(page, self.page.locator(loc), "password_input")
|
password_input = TextInput(page, loc, "password_input")
|
||||||
self.add_content_item("password_input", password_input)
|
self.add_content_item("password_input", password_input)
|
||||||
|
|
||||||
# Поле Комментарий
|
# Поле Комментарий
|
||||||
loc = f"{input_form_locator}/div[5]/{text_field_locator}"
|
loc = elements_locators.get("Комментарий").locator(text_field_locator)
|
||||||
commentary_input = TextInput(page, self.page.locator(loc), "commentary_input")
|
commentary_input = TextInput(page, loc, "commentary_input")
|
||||||
self.add_content_item("commentary_input", commentary_input)
|
self.add_content_item("commentary_input", commentary_input)
|
||||||
|
|
||||||
# Поле E-mail
|
# Поле E-mail
|
||||||
loc = f"{input_form_locator}/div[6]/{text_field_locator}"
|
loc = elements_locators.get("E-mail").locator(text_field_locator)
|
||||||
email_input = TextInput(page, self.page.locator(loc), "email_input")
|
email_input = TextInput(page, loc, "email_input")
|
||||||
self.add_content_item("email_input", email_input)
|
self.add_content_item("email_input", email_input)
|
||||||
|
|
||||||
# Поле Номер для СМС
|
# Поле Номер для СМС
|
||||||
loc = f"{input_form_locator}/div[7]/{text_field_locator}"
|
loc = elements_locators.get("Номер для СМС").locator(text_field_locator)
|
||||||
phone_input = TextInput(page, self.page.locator(loc), "phone_input")
|
phone_input = TextInput(page, loc, "phone_input")
|
||||||
self.add_content_item("phone_input", phone_input)
|
self.add_content_item("phone_input", phone_input)
|
||||||
|
|
||||||
# Метка "Подписка на Push-уведомления"
|
# Метка "Подписка на Push-уведомления"
|
||||||
|
|
@ -112,7 +116,7 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
)
|
)
|
||||||
self.add_content_item("push_notification_checkbox_label", label_push)
|
self.add_content_item("push_notification_checkbox_label", label_push)
|
||||||
|
|
||||||
# Чекбокс "Подписка на Push-уведомления" - индекс 2
|
# Чекбокс "Подписка на Push-уведомления"
|
||||||
checkbox_push = Checkbox(
|
checkbox_push = Checkbox(
|
||||||
page,
|
page,
|
||||||
label_push_locator.locator("../..").get_by_role("checkbox"),
|
label_push_locator.locator("../..").get_by_role("checkbox"),
|
||||||
|
|
@ -151,6 +155,20 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
|
|
||||||
self.get_content_item("push_notification_checkbox").uncheck(force=True)
|
self.get_content_item("push_notification_checkbox").uncheck(force=True)
|
||||||
|
|
||||||
|
def get_auth_type(self) -> str:
|
||||||
|
"""Возвращает текущее значение поля 'Тип авторизации'"""
|
||||||
|
|
||||||
|
values = self.get_content_item("auth_type_selector").get_selected_values()
|
||||||
|
return values[0]
|
||||||
|
|
||||||
|
def select_auth_type(self, auth_type: str) -> None:
|
||||||
|
"""Выбирает заданное значение поля 'Тип авторизации' из списка"""
|
||||||
|
|
||||||
|
auth_type_selector = self.get_content_item("auth_type_selector")
|
||||||
|
|
||||||
|
auth_type_selector.open_values_list()
|
||||||
|
auth_type_selector.select_value(auth_type)
|
||||||
|
|
||||||
def new_user(self, user_data):
|
def new_user(self, user_data):
|
||||||
"""Заполняет форму и добавляет нового пользователя.
|
"""Заполняет форму и добавляет нового пользователя.
|
||||||
|
|
||||||
|
|
@ -158,11 +176,83 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
user_data (dict): Данные пользователя (имя, роль, пароль и др.)
|
user_data (dict): Данные пользователя (имя, роль, пароль и др.)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fields = user_data.keys()
|
auth_type = user_data.get("auth_type")
|
||||||
|
if auth_type is None:
|
||||||
|
auth_type = 'local'
|
||||||
|
|
||||||
if "name" in fields:
|
current_auth_type = self.get_auth_type()
|
||||||
|
if current_auth_type != auth_type:
|
||||||
|
self.select_auth_type(auth_type)
|
||||||
|
|
||||||
|
if auth_type == "LDAP":
|
||||||
|
menu_locator = self.page.locator(ModalWindowLocators.MENU_ACTIVE_INPUT_FORM)
|
||||||
|
|
||||||
|
elements_locators = self._get_fields_locators(self.page)
|
||||||
|
|
||||||
|
# Добавилось поле Группа
|
||||||
|
group_loc = elements_locators.get("Группа").get_by_role("combobox")
|
||||||
|
group_input = TextInput(self.page, group_loc, "group_input")
|
||||||
|
self.add_content_item("group_input", group_input)
|
||||||
|
self.add_content_item("group_list", DropdownList(self.page))
|
||||||
|
|
||||||
|
# Добавилась кнопка Поиск
|
||||||
|
locator_button_search = self.page.get_by_role("button", name="Поиск")
|
||||||
|
self.add_button(locator_button_search, "search")
|
||||||
|
|
||||||
|
# Поиск и выбор заданной группы из списка существующих
|
||||||
|
group_field = self.get_content_item("group_input")
|
||||||
|
group_field.click()
|
||||||
|
|
||||||
|
group_name = user_data["group"]
|
||||||
|
group_list = self.get_content_item("group_list")
|
||||||
|
group_list.scroll_until_end(menu_locator)
|
||||||
|
group_names = group_list.get_item_names(menu_locator)
|
||||||
|
if group_name not in group_names:
|
||||||
|
assert False, f"Required group name {group_name} is missing"
|
||||||
|
|
||||||
|
group_list.check_item_with_text(group_name)
|
||||||
|
group_list.click_item_with_text(group_name)
|
||||||
|
|
||||||
|
# Нажатие кнопки "Поиск"
|
||||||
|
search_button = self.get_button_by_name("search")
|
||||||
|
search_button.click()
|
||||||
|
|
||||||
|
# Если в группе есть пользователи, открывается новое поле, заново вычисляем локаторы
|
||||||
|
elements_locators = self._get_fields_locators(self.page)
|
||||||
|
users_ad_loc = elements_locators.get("Пользователи AD")
|
||||||
|
# users_ad_loc = elements_locators.get("Пользователи LDAP")
|
||||||
|
assert users_ad_loc, f"Selected group {group_name} is empty. Use another group."
|
||||||
|
|
||||||
|
# Поиск и выбор заданного пользователя AD из списка существующих
|
||||||
|
user_ldap_loc = users_ad_loc.get_by_role("combobox")
|
||||||
|
user_ldap_input = TextInput(self.page, user_ldap_loc, "user__input")
|
||||||
|
self.add_content_item("user_ldap_input", user_ldap_input)
|
||||||
|
self.add_content_item(
|
||||||
|
"user_ldap_list",
|
||||||
|
DropdownList(self.page)
|
||||||
|
)
|
||||||
|
|
||||||
|
user_ldap_input.click()
|
||||||
|
user_ldap_list = self.get_content_item("user_ldap_list")
|
||||||
|
user_ldap_list.scroll_until_end(menu_locator)
|
||||||
|
user_ldap_names = group_list.get_item_names(menu_locator)
|
||||||
|
name_ldap = user_data.get("name_ldap")
|
||||||
|
if name_ldap not in user_ldap_names:
|
||||||
|
assert False, f"Required user name {name_ldap} is missing"
|
||||||
|
|
||||||
|
user_ldap_list.check_item_with_text(name_ldap)
|
||||||
|
user_ldap_list.click_item_with_text(name_ldap)
|
||||||
|
|
||||||
|
# Заново вычисляем локаторы полей ввода
|
||||||
|
self.locators_recalculation(is_active_directory=True)
|
||||||
|
|
||||||
|
# Заполнение поля "Имя" (ручной ввод) если задано
|
||||||
|
name = user_data.get("name")
|
||||||
|
if name:
|
||||||
input_field = self.get_content_item("name_input")
|
input_field = self.get_content_item("name_input")
|
||||||
input_field.input_value(user_data["name"])
|
input_field.input_value(name)
|
||||||
|
|
||||||
|
fields = user_data.keys()
|
||||||
|
|
||||||
if "role" in fields:
|
if "role" in fields:
|
||||||
role_field = self.get_content_item("role_input")
|
role_field = self.get_content_item("role_input")
|
||||||
|
|
@ -225,11 +315,55 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
|
|
||||||
self.click_toolbar_close_button()
|
self.click_toolbar_close_button()
|
||||||
|
|
||||||
|
def locators_recalculation(self, is_active_directory=False) -> None:
|
||||||
|
"""Пересчет локаторов полей ввода"""
|
||||||
|
|
||||||
|
text_field_locator = f"//{ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA}"
|
||||||
|
|
||||||
|
elements_locators = self._get_fields_locators(self.page)
|
||||||
|
|
||||||
|
new_loc = elements_locators.get("Имя").locator(text_field_locator)
|
||||||
|
self.get_content_item("name_input").update_locator(new_loc)
|
||||||
|
|
||||||
|
if not is_active_directory:
|
||||||
|
new_loc = elements_locators.get("Пароль").locator(text_field_locator)
|
||||||
|
self.get_content_item("password_input").update_locator(new_loc)
|
||||||
|
|
||||||
|
new_loc = elements_locators.get("Роль").get_by_role("combobox")
|
||||||
|
self.get_content_item("role_input").update_locator(new_loc)
|
||||||
|
|
||||||
|
new_loc = elements_locators.get("Комментарий").locator(text_field_locator)
|
||||||
|
self.get_content_item("commentary_input").update_locator(new_loc)
|
||||||
|
|
||||||
|
new_loc = elements_locators.get("E-mail").locator(text_field_locator)
|
||||||
|
self.get_content_item("email_input").update_locator(new_loc)
|
||||||
|
|
||||||
|
new_loc = elements_locators.get("Номер для СМС").locator(text_field_locator)
|
||||||
|
self.get_content_item("phone_input").update_locator(new_loc)
|
||||||
|
|
||||||
|
def _get_fields_locators(self, page) -> dict:
|
||||||
|
fields_locators = {}
|
||||||
|
elements = page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA). \
|
||||||
|
locator("div.v-text-field__slot > input").all()
|
||||||
|
for el in elements:
|
||||||
|
val = el.input_value().strip()
|
||||||
|
if val:
|
||||||
|
fields_locators[val] = el.locator("../ancestor::div[5]")
|
||||||
|
return fields_locators
|
||||||
|
|
||||||
# Проверки:
|
# Проверки:
|
||||||
def check_content(self):
|
def check_content(self):
|
||||||
"""Проверяет наличие и корректность всех элементов формы."""
|
"""Проверяет наличие и корректность всех элементов формы создания локального пользователя.
|
||||||
|
Форма для создания keycloack пользователя имеет тот же набор полей.
|
||||||
|
"""
|
||||||
|
|
||||||
menu_locator = self.page.locator(ModalWindowLocators.MENU_INPUT_FORM_USER_DATA)
|
expected_auth_types = ['local', 'LDAP', 'keycloack']
|
||||||
|
expected_roles = ['$collector', 'Администратор',
|
||||||
|
'Специалист информационной безопасности',
|
||||||
|
'Контактное лицо', 'Оператор']
|
||||||
|
|
||||||
|
menu_locator = self.page.locator(ModalWindowLocators.MENU_ACTIVE_INPUT_FORM)
|
||||||
|
items_locator = menu_locator.locator(ModalWindowLocators.MENU_ACTIVE_ITEMS)
|
||||||
|
|
||||||
self.check_by_window_title()
|
self.check_by_window_title()
|
||||||
|
|
||||||
|
|
@ -252,6 +386,13 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
"Подписка на Push-уведомления",
|
"Подписка на Push-уведомления",
|
||||||
"Label 'Подписка на Push-уведомления' is missing"
|
"Label 'Подписка на Push-уведомления' is missing"
|
||||||
)
|
)
|
||||||
|
elif name == "auth_type_selector":
|
||||||
|
current_auth_type = self.get_auth_type()
|
||||||
|
assert current_auth_type == 'local', "Default Auth Type value should be 'local'"
|
||||||
|
|
||||||
|
actual_auth_types = item.get_available_options(items_locator)
|
||||||
|
assert actual_auth_types == expected_auth_types, \
|
||||||
|
f"Actual auth types {actual_auth_types} are not equal expected values {expected_auth_types}."
|
||||||
elif name == "role_input":
|
elif name == "role_input":
|
||||||
item.click()
|
item.click()
|
||||||
roles_list = self.get_content_item("roles_list")
|
roles_list = self.get_content_item("roles_list")
|
||||||
|
|
@ -262,10 +403,7 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
"Roles list should not be scrollable_vertically"
|
"Roles list should not be scrollable_vertically"
|
||||||
)
|
)
|
||||||
|
|
||||||
for role in roles_dict.values():
|
for role in expected_roles:
|
||||||
# временно, пока есть несоответствие со списком ролей в вкладке Сессии
|
|
||||||
if role == "Пользователь":
|
|
||||||
continue
|
|
||||||
roles_list.check_item_with_text(role)
|
roles_list.check_item_with_text(role)
|
||||||
elif name in input_fields:
|
elif name in input_fields:
|
||||||
item.check_editable_input(
|
item.check_editable_input(
|
||||||
|
|
@ -293,5 +431,32 @@ class AddLocalUserModalWindow(ModalWindowComponent):
|
||||||
"Checkbox 'Подписка на Push-уведомления' should not be checked by default"
|
"Checkbox 'Подписка на Push-уведомления' should not be checked by default"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Выбор типа авторизации LDAP и проверка появления поля Группа и кнопки Поиск
|
||||||
|
self.select_auth_type("LDAP")
|
||||||
|
|
||||||
|
elements_locators = self._get_fields_locators(self.page)
|
||||||
|
|
||||||
|
# Добавилось поле Группа
|
||||||
|
group_loc = elements_locators.get("Группа").get_by_role("combobox")
|
||||||
|
group_input = TextInput(self.page, group_loc, "group_input")
|
||||||
|
self.add_content_item("group_input", group_input)
|
||||||
|
self.add_content_item("group_list", DropdownList(self.page))
|
||||||
|
|
||||||
|
group_field = self.get_content_item("group_input")
|
||||||
|
group_field.click()
|
||||||
|
|
||||||
|
group_list = self.get_content_item("group_list")
|
||||||
|
group_list.check_visibility(menu_locator,
|
||||||
|
"Groups list is missing")
|
||||||
|
|
||||||
|
is_scrollable_vertically = group_list.check_vertical_scrolling(menu_locator)
|
||||||
|
assert is_scrollable_vertically, "Groups list should be scrollable_vertically"
|
||||||
|
self.page.keyboard.press("Escape")
|
||||||
|
|
||||||
|
# Добавилась кнопка Поиск
|
||||||
|
locator_button_search = self.page.get_by_role("button", name="Поиск")
|
||||||
|
self.add_button(locator_button_search, "search")
|
||||||
|
self.check_button_visibility("search")
|
||||||
|
|
||||||
self.check_button_visibility("add")
|
self.check_button_visibility("add")
|
||||||
self.check_button_visibility("close")
|
self.check_button_visibility("close")
|
||||||
|
|
@ -37,7 +37,6 @@ class EditUserModalWindow(ModalWindowComponent):
|
||||||
# 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}"
|
text_field_locator = f"xpath={ModalWindowLocators.TEXT_FIELD_INPUT_FORM_USER_DATA}"
|
||||||
input_form_locator = ModalWindowLocators.INPUT_FORM_USER_DATA
|
input_form_locator = ModalWindowLocators.INPUT_FORM_USER_DATA
|
||||||
label_locator = ModalWindowLocators.LABEL_INPUT_FORM_USER_DATA
|
|
||||||
|
|
||||||
# Настройка заголовка и кнопки закрытия
|
# Настройка заголовка и кнопки закрытия
|
||||||
self.window_title = user_name
|
self.window_title = user_name
|
||||||
|
|
@ -51,83 +50,71 @@ class EditUserModalWindow(ModalWindowComponent):
|
||||||
self.add_toolbar_button(locator_button_toolbar_close, "close")
|
self.add_toolbar_button(locator_button_toolbar_close, "close")
|
||||||
|
|
||||||
# Добавление полей формы
|
# Добавление полей формы
|
||||||
|
elements_locators = self._get_fields_locators(page)
|
||||||
|
|
||||||
# Поле Имя
|
# Поле Имя
|
||||||
loc = (
|
loc = elements_locators.get("Имя").locator(text_field_locator)
|
||||||
self.page.locator(input_form_locator)
|
|
||||||
.locator("xpath=div[1]")
|
|
||||||
.locator(text_field_locator)
|
|
||||||
)
|
|
||||||
name_input = TextInput(page, loc, "name_input")
|
name_input = TextInput(page, loc, "name_input")
|
||||||
self.add_content_item("name_input", name_input)
|
self.add_content_item("name_input", name_input)
|
||||||
|
|
||||||
# Поле Роль
|
# Поле Роль
|
||||||
role_loc = self.page.locator(input_form_locator).get_by_role("combobox").nth(0)
|
role_loc = self.page.locator(input_form_locator).get_by_role("combobox")
|
||||||
role_input = TextInput(page, role_loc, "role_input")
|
role_input = TextInput(page, role_loc, "role_input")
|
||||||
self.add_content_item("role_input", role_input)
|
self.add_content_item("role_input", role_input)
|
||||||
self.add_content_item("roles_list", DropdownList(page))
|
self.add_content_item("roles_list", DropdownList(page))
|
||||||
|
|
||||||
# Поле Комментарий
|
# Поле Комментарий
|
||||||
loc = (
|
loc = elements_locators.get("Комментарий").locator(text_field_locator)
|
||||||
self.page.locator(input_form_locator)
|
|
||||||
.locator("xpath=div[4]")
|
|
||||||
.locator(text_field_locator)
|
|
||||||
)
|
|
||||||
commentary_input = TextInput(page, loc, "commentary_input")
|
commentary_input = TextInput(page, loc, "commentary_input")
|
||||||
self.add_content_item("commentary_input", commentary_input)
|
self.add_content_item("commentary_input", commentary_input)
|
||||||
|
|
||||||
# Поле E-mail
|
# Поле E-mail
|
||||||
loc = (
|
loc = elements_locators.get("E-mail").locator(text_field_locator)
|
||||||
self.page.locator(input_form_locator)
|
|
||||||
.locator("xpath=div[5]")
|
|
||||||
.locator(text_field_locator)
|
|
||||||
)
|
|
||||||
email_input = TextInput(page, loc, "email_input")
|
email_input = TextInput(page, loc, "email_input")
|
||||||
self.add_content_item("email_input", email_input)
|
self.add_content_item("email_input", email_input)
|
||||||
|
|
||||||
# Поле Номер для СМС
|
# Поле Номер для СМС
|
||||||
loc = (
|
loc = elements_locators.get("Номер для СМС").locator(text_field_locator)
|
||||||
self.page.locator(input_form_locator)
|
|
||||||
.locator("xpath=div[6]")
|
|
||||||
.locator(text_field_locator)
|
|
||||||
)
|
|
||||||
phone_input = TextInput(page, loc, "phone_input")
|
phone_input = TextInput(page, loc, "phone_input")
|
||||||
self.add_content_item("phone_input", phone_input)
|
self.add_content_item("phone_input", phone_input)
|
||||||
|
|
||||||
# Добавление чекбоксов и их меток
|
# Добавление чекбоксов и их меток
|
||||||
|
# Метка "Блокировка"
|
||||||
# Чекбокс "Блокировка" - теперь индекс 0 (т.к. нет Active Directory)
|
label_blocking_locator = self.page.locator(input_form_locator). \
|
||||||
checkbox_1 = Checkbox(
|
locator("//label").get_by_text("Блокировка")
|
||||||
|
label_blocking = Text(
|
||||||
page,
|
page,
|
||||||
self.page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA)
|
label_blocking_locator,
|
||||||
.get_by_role("checkbox").nth(0),
|
|
||||||
"blocking"
|
|
||||||
)
|
|
||||||
self.add_content_item("blocking_checkbox", checkbox_1)
|
|
||||||
|
|
||||||
# Метка "Блокировка" - индекс 0
|
|
||||||
label_1 = Text(
|
|
||||||
page,
|
|
||||||
self.page.locator(label_locator).nth(0),
|
|
||||||
"blocking_checkbox_label"
|
"blocking_checkbox_label"
|
||||||
)
|
)
|
||||||
self.add_content_item("blocking_checkbox_label", label_1)
|
|
||||||
|
|
||||||
# Чекбокс "Подписка на Push-уведомления" - индекс 1
|
self.add_content_item("blocking_checkbox_label", label_blocking)
|
||||||
checkbox_2 = Checkbox(
|
|
||||||
|
# Чекбокс "Блокировка"
|
||||||
|
checkbox_blocking = Checkbox(
|
||||||
page,
|
page,
|
||||||
self.page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA)
|
label_blocking_locator.locator("../..").get_by_role("checkbox"),
|
||||||
.get_by_role("checkbox").nth(1),
|
"blocking"
|
||||||
"push_notification"
|
|
||||||
)
|
)
|
||||||
self.add_content_item("push_notification_checkbox", checkbox_2)
|
self.add_content_item("blocking_checkbox", checkbox_blocking)
|
||||||
|
|
||||||
# Метка "Подписка на Push-уведомления" - индекс 1
|
# Метка "Подписка на Push-уведомления"
|
||||||
label_2 = Text(
|
label_push_locator = self.page.locator(input_form_locator). \
|
||||||
|
locator("//label").get_by_text("Подписка на Push-уведомления")
|
||||||
|
label_push = Text(
|
||||||
page,
|
page,
|
||||||
self.page.locator(label_locator).nth(1),
|
label_push_locator,
|
||||||
"push_notification_checkbox_label"
|
"push_notification_checkbox_label"
|
||||||
)
|
)
|
||||||
self.add_content_item("push_notification_checkbox_label", label_2)
|
self.add_content_item("push_notification_checkbox_label", label_push)
|
||||||
|
|
||||||
|
# Чекбокс "Подписка на Push-уведомления"
|
||||||
|
checkbox_push = Checkbox(
|
||||||
|
page,
|
||||||
|
label_push_locator.locator("../..").get_by_role("checkbox"),
|
||||||
|
"push_notification"
|
||||||
|
)
|
||||||
|
self.add_content_item("push_notification_checkbox", checkbox_push)
|
||||||
|
|
||||||
# Добавление кнопок действий
|
# Добавление кнопок действий
|
||||||
locator_button_save = self.page.get_by_role("button", name="Сохранить")
|
locator_button_save = self.page.get_by_role("button", name="Сохранить")
|
||||||
|
|
@ -254,6 +241,16 @@ class EditUserModalWindow(ModalWindowComponent):
|
||||||
reset_password_button = self.get_button_by_name("reset_password")
|
reset_password_button = self.get_button_by_name("reset_password")
|
||||||
reset_password_button.click()
|
reset_password_button.click()
|
||||||
|
|
||||||
|
def _get_fields_locators(self, page) -> dict:
|
||||||
|
fields_locators = {}
|
||||||
|
elements = page.locator(ModalWindowLocators.INPUT_FORM_USER_DATA). \
|
||||||
|
locator("div.v-text-field__slot > input").all()
|
||||||
|
for el in elements:
|
||||||
|
val = el.input_value().strip()
|
||||||
|
if val:
|
||||||
|
fields_locators[val] = el.locator("../ancestor::div[5]")
|
||||||
|
return fields_locators
|
||||||
|
|
||||||
# Проверки:
|
# Проверки:
|
||||||
def check_content(self, user_name, role):
|
def check_content(self, user_name, role):
|
||||||
"""Проверяет наличие и корректность элементов окна.
|
"""Проверяет наличие и корректность элементов окна.
|
||||||
|
|
@ -263,7 +260,7 @@ class EditUserModalWindow(ModalWindowComponent):
|
||||||
role (str): Ожидаемая роль пользователя
|
role (str): Ожидаемая роль пользователя
|
||||||
"""
|
"""
|
||||||
|
|
||||||
menu_locator = self.page.locator(ModalWindowLocators.MENU_INPUT_FORM_USER_DATA)
|
menu_locator = self.page.locator(ModalWindowLocators.MENU_ACTIVE_INPUT_FORM)
|
||||||
|
|
||||||
self.check_by_window_title()
|
self.check_by_window_title()
|
||||||
self.check_toolbar_button_visibility("close")
|
self.check_toolbar_button_visibility("close")
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ class SelectionBarComponent(BaseComponent):
|
||||||
locator_or_text: Локатор панели выбора значения (строка или объект Locator)
|
locator_or_text: Локатор панели выбора значения (строка или объект Locator)
|
||||||
или текст для поиска
|
или текст для поиска
|
||||||
"""
|
"""
|
||||||
|
|
||||||
super().__init__(page)
|
super().__init__(page)
|
||||||
|
|
||||||
# Определяем локатор в зависимости от типа параметра
|
# Определяем локатор в зависимости от типа параметра
|
||||||
|
|
@ -48,7 +47,6 @@ class SelectionBarComponent(BaseComponent):
|
||||||
# Действия:
|
# Действия:
|
||||||
def clear_selections(self) -> None:
|
def clear_selections(self) -> None:
|
||||||
"""Удаление ранее выбранных значений"""
|
"""Удаление ранее выбранных значений"""
|
||||||
|
|
||||||
selected_values = self.get_selected_values()
|
selected_values = self.get_selected_values()
|
||||||
if len(selected_values) > 0:
|
if len(selected_values) > 0:
|
||||||
clear_button_locator = self.selection_bar_locator.locator(
|
clear_button_locator = self.selection_bar_locator.locator(
|
||||||
|
|
@ -56,13 +54,12 @@ class SelectionBarComponent(BaseComponent):
|
||||||
)
|
)
|
||||||
clear_button_locator.click()
|
clear_button_locator.click()
|
||||||
|
|
||||||
def get_available_options(self) -> list[str]:
|
def get_available_options(self, locator=None) -> list[str]:
|
||||||
"""Возвращает список всех доступных опций из выпадающего списка.
|
"""Возвращает список всех доступных опций из выпадающего списка.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
list[str]: Список доступных опций
|
list[str]: Список доступных опций
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logger.info("Getting available options from dropdown list...")
|
logger.info("Getting available options from dropdown list...")
|
||||||
|
|
||||||
# Открываем выпадающий список
|
# Открываем выпадающий список
|
||||||
|
|
@ -72,9 +69,10 @@ class SelectionBarComponent(BaseComponent):
|
||||||
self.wait_for_timeout(1000)
|
self.wait_for_timeout(1000)
|
||||||
|
|
||||||
# Получаем все элементы списка
|
# Получаем все элементы списка
|
||||||
options = self.selected_values_list.get_item_names(
|
if locator:
|
||||||
SelectionBarLocators.LIST_ITEMS
|
options = self.selected_values_list.get_item_names(locator)
|
||||||
)
|
else:
|
||||||
|
options = self.selected_values_list.get_item_names(SelectionBarLocators.LIST_ITEMS)
|
||||||
|
|
||||||
# Закрываем список (кликаем вне его)
|
# Закрываем список (кликаем вне его)
|
||||||
self.page.mouse.click(10, 10)
|
self.page.mouse.click(10, 10)
|
||||||
|
|
@ -85,18 +83,21 @@ class SelectionBarComponent(BaseComponent):
|
||||||
|
|
||||||
def get_selection_bar_title(self) -> str:
|
def get_selection_bar_title(self) -> str:
|
||||||
"""Возвращает название панели выбора значения"""
|
"""Возвращает название панели выбора значения"""
|
||||||
|
|
||||||
title_locator = self.selection_bar_locator.locator(SelectionBarLocators.TITLE_LOCATOR)
|
title_locator = self.selection_bar_locator.locator(SelectionBarLocators.TITLE_LOCATOR)
|
||||||
return title_locator.text_content()
|
return title_locator.text_content()
|
||||||
|
|
||||||
def get_selected_values(self) -> list[str]:
|
def get_selected_values(self) -> list[str]:
|
||||||
"""Возвращает список выбранных значений"""
|
"""Возвращает список выбранных значений"""
|
||||||
|
|
||||||
selected_values_locator = self.selection_bar_locator.locator(
|
selected_values_locator = self.selection_bar_locator.locator(
|
||||||
SelectionBarLocators.PARAMETERS_SELECTED
|
SelectionBarLocators.PARAMETERS_SELECTED
|
||||||
)
|
)
|
||||||
selected_values = selected_values_locator.all_inner_texts()
|
selected_values = selected_values_locator.all_inner_texts()
|
||||||
return selected_values[0].splitlines()
|
ret_value = []
|
||||||
|
if len(selected_values[0]) > 1:
|
||||||
|
ret_value = selected_values[0].splitlines()
|
||||||
|
elif len(selected_values[0]) == 1:
|
||||||
|
ret_value.append(selected_values[0])
|
||||||
|
return ret_value
|
||||||
|
|
||||||
def clear_combobox_field(self, field_name: str, field_locator: str) -> None:
|
def clear_combobox_field(self, field_name: str, field_locator: str) -> None:
|
||||||
"""Очищает значение в combobox поле с помощью кнопки закрытия (крестика).
|
"""Очищает значение в combobox поле с помощью кнопки закрытия (крестика).
|
||||||
|
|
@ -105,7 +106,6 @@ class SelectionBarComponent(BaseComponent):
|
||||||
field_name: Название поля для очистки
|
field_name: Название поля для очистки
|
||||||
field_locator: Локатор поля combobox
|
field_locator: Локатор поля combobox
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logger.info(f"Clearing combobox field '{field_name}' using close button...")
|
logger.info(f"Clearing combobox field '{field_name}' using close button...")
|
||||||
|
|
||||||
# Находим поле по локатору
|
# Находим поле по локатору
|
||||||
|
|
@ -138,7 +138,6 @@ class SelectionBarComponent(BaseComponent):
|
||||||
|
|
||||||
def open_values_list(self) -> None:
|
def open_values_list(self) -> None:
|
||||||
"""Открытие выпадающего списка путем нажатия на панель выбора значения"""
|
"""Открытие выпадающего списка путем нажатия на панель выбора значения"""
|
||||||
|
|
||||||
expect(self.selection_bar_locator).to_be_visible()
|
expect(self.selection_bar_locator).to_be_visible()
|
||||||
|
|
||||||
# Проверяем, не открыт ли уже список
|
# Проверяем, не открыт ли уже список
|
||||||
|
|
@ -156,20 +155,26 @@ class SelectionBarComponent(BaseComponent):
|
||||||
|
|
||||||
def select_value(self, name: str) -> None:
|
def select_value(self, name: str) -> None:
|
||||||
"""Выбор значения из списка"""
|
"""Выбор значения из списка"""
|
||||||
|
|
||||||
self.selected_values_list.check_item_with_text(name)
|
self.selected_values_list.check_item_with_text(name)
|
||||||
self.selected_values_list.click_item_with_text(name)
|
self.selected_values_list.click_item_with_text(name)
|
||||||
|
|
||||||
|
def wait_for_timeout(self, timeout: int) -> None:
|
||||||
|
"""Ожидает указанное количество миллисекунд.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
timeout: Время ожидания в миллисекундах
|
||||||
|
"""
|
||||||
|
self.page.wait_for_timeout(timeout)
|
||||||
|
|
||||||
# Проверки:
|
# Проверки:
|
||||||
|
|
||||||
def check_field_error_highlighted(self, field_name: str, field_locator: str) -> None:
|
def check_field_highlighted_error(self, field_name: str, field_locator: str) -> None:
|
||||||
"""Проверяет, что поле подсвечено цветом ошибки (валидация не пройдена).
|
"""Проверяет, что поле подсвечено цветом ошибки (валидация не пройдена).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
field_name: Название поля для проверки
|
field_name: Название поля для проверки
|
||||||
field_locator: Локатор поля для проверки
|
field_locator: Локатор поля для проверки
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logger.info(f"Checking field '{field_name}' for error highlighting...")
|
logger.info(f"Checking field '{field_name}' for error highlighting...")
|
||||||
|
|
||||||
field_element = self.page.locator(field_locator).first
|
field_element = self.page.locator(field_locator).first
|
||||||
|
|
@ -184,18 +189,18 @@ class SelectionBarComponent(BaseComponent):
|
||||||
if parent_container.count() > 0:
|
if parent_container.count() > 0:
|
||||||
has_error = parent_container.locator(SelectionBarLocators.ERROR_CSS_SELECTORS).count() > 0
|
has_error = parent_container.locator(SelectionBarLocators.ERROR_CSS_SELECTORS).count() > 0
|
||||||
|
|
||||||
assert has_error, f"Field '{field_name}' is not highlighted with error color"
|
if not has_error:
|
||||||
|
raise AssertionError(f"Field '{field_name}' is not highlighted with error color")
|
||||||
|
|
||||||
logger.info(f"Field '{field_name}' is correctly highlighted with error color")
|
logger.info(f"Field '{field_name}' is correctly highlighted with error color")
|
||||||
|
|
||||||
def check_field_error_not_highlighted(self, field_name: str, field_locator: str) -> None:
|
def check_field_not_highlighted_error(self, field_name: str, field_locator: str) -> None:
|
||||||
"""Проверяет, что поле НЕ подсвечено цветом ошибки (валидация успешна).
|
"""Проверяет, что поле НЕ подсвечено цветом ошибки (валидация успешна).
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
field_name: Название поля для проверки
|
field_name: Название поля для проверки
|
||||||
field_locator: Локатор поля для проверки
|
field_locator: Локатор поля для проверки
|
||||||
"""
|
"""
|
||||||
|
|
||||||
logger.info(f"Checking field '{field_name}' for absence of error highlighting...")
|
logger.info(f"Checking field '{field_name}' for absence of error highlighting...")
|
||||||
|
|
||||||
field_element = self.page.locator(field_locator).first
|
field_element = self.page.locator(field_locator).first
|
||||||
|
|
@ -206,10 +211,11 @@ class SelectionBarComponent(BaseComponent):
|
||||||
# Ищем родительский контейнер
|
# Ищем родительский контейнер
|
||||||
parent_container = field_element.locator(SelectionBarLocators.INPUT_PARENT_CONTAINER).first
|
parent_container = field_element.locator(SelectionBarLocators.INPUT_PARENT_CONTAINER).first
|
||||||
|
|
||||||
# Проверяем отсутствие классов ошибки
|
# Проверяем отсутствие классов ошибки с использованием локатора из SelectionBarLocators
|
||||||
if parent_container.count() > 0:
|
if parent_container.count() > 0:
|
||||||
has_error = parent_container.locator(SelectionBarLocators.ERROR_CSS_SELECTORS).count() > 0
|
has_error = parent_container.locator(SelectionBarLocators.ERROR_CSS_SELECTORS).count() > 0
|
||||||
|
|
||||||
assert not has_error, f"Field '{field_name}' is highlighted with error"
|
if has_error:
|
||||||
|
raise AssertionError(f"Field '{field_name}' is highlighted with error")
|
||||||
|
|
||||||
logger.info(f"Field '{field_name}' correctly has no error highlighting")
|
logger.info(f"Field '{field_name}' correctly has no error highlighting")
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class ModalWindowLocators:
|
||||||
INPUT_FORM_USER_DATA = f"{MODAL_WINDOW}//form[@class='v-form']"
|
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 = "div[2]/div/div/div/div/input"
|
||||||
# TEXT_FIELD_INPUT_FORM_USER_DATA = "xpath=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')]"
|
MENU_ACTIVE_INPUT_FORM = "//div[contains(@class, 'menuable__content__active')]"
|
||||||
|
MENU_ACTIVE_ITEMS = "//div[@role='list']//div[@role='listitem']"
|
||||||
LABEL_INPUT_FORM_USER_DATA = "//label[contains(@class,'v-label')]/span"
|
LABEL_INPUT_FORM_USER_DATA = "//label[contains(@class,'v-label')]/span"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@ import re
|
||||||
from playwright.sync_api import Page
|
from playwright.sync_api import Page
|
||||||
from locators.table_locators import TableLocators
|
from locators.table_locators import TableLocators
|
||||||
from components_derived.modal_edit_user import EditUserModalWindow
|
from components_derived.modal_edit_user import EditUserModalWindow
|
||||||
from components_derived.modal_add_local_user import AddLocalUserModalWindow
|
from components_derived.modal_add_user import AddUserModalWindow
|
||||||
from components_derived.modal_add_AD_user import AddADUserModalWindow
|
|
||||||
from data.roles_dict import roles_dict
|
from data.roles_dict import roles_dict
|
||||||
from components.toolbar_component import ToolbarComponent
|
from components.toolbar_component import ToolbarComponent
|
||||||
from components.table_component import TableComponent
|
from components.table_component import TableComponent
|
||||||
|
|
@ -62,10 +61,8 @@ class UsersTab(BasePage):
|
||||||
AssertionError: Если тип окна не поддерживается.
|
AssertionError: Если тип окна не поддерживается.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if window_type == "add_local_user":
|
if window_type == "add_user":
|
||||||
self.modal_windows["add_local_user"] = AddLocalUserModalWindow(self.page)
|
self.modal_windows["add_user"] = AddUserModalWindow(self.page)
|
||||||
elif window_type == "add_AD_user":
|
|
||||||
self.modal_windows["add_AD_user"] = AddADUserModalWindow(self.page)
|
|
||||||
elif window_type == "edit_user":
|
elif window_type == "edit_user":
|
||||||
self.modal_windows[title] = EditUserModalWindow(self.page, title)
|
self.modal_windows[title] = EditUserModalWindow(self.page, title)
|
||||||
else:
|
else:
|
||||||
|
|
@ -85,14 +82,7 @@ class UsersTab(BasePage):
|
||||||
или если текст alert не соответствует ожидаемому.
|
или если текст alert не соответствует ожидаемому.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
add_user_window = self.get_modal_window("add_local_user")
|
add_user_window = self.get_modal_window("add_user")
|
||||||
|
|
||||||
# skip as unsupported
|
|
||||||
# auth_type = user_data.get("auth_type")
|
|
||||||
# if auth_type == "active_directory":
|
|
||||||
# add_user_window.check_active_directory_checkbox()
|
|
||||||
# self.add_modal_window("add_AD_user", "")
|
|
||||||
# add_user_window = self.get_modal_window("add_AD_user")
|
|
||||||
|
|
||||||
add_user_window.new_user(user_data)
|
add_user_window.new_user(user_data)
|
||||||
|
|
||||||
|
|
@ -110,25 +100,15 @@ class UsersTab(BasePage):
|
||||||
|
|
||||||
return is_added
|
return is_added
|
||||||
|
|
||||||
def close_add_AD_user_window(self) -> None:
|
|
||||||
"""Закрывает окно добавления пользователя."""
|
|
||||||
|
|
||||||
self.close_modal_window("add_AD_user")
|
|
||||||
|
|
||||||
def close_add_AD_user_window_by_toolbar_button(self) -> None:
|
|
||||||
"""Закрывает окно добавления пользователя через тулбар."""
|
|
||||||
|
|
||||||
self.close_modal_window_by_toolbar_button("add_AD_user")
|
|
||||||
|
|
||||||
def close_add_user_window(self) -> None:
|
def close_add_user_window(self) -> None:
|
||||||
"""Закрывает окно добавления пользователя."""
|
"""Закрывает окно добавления пользователя."""
|
||||||
|
|
||||||
self.close_modal_window("add_local_user")
|
self.close_modal_window("add_user")
|
||||||
|
|
||||||
def close_add_user_window_by_toolbar_button(self) -> None:
|
def close_add_user_window_by_toolbar_button(self) -> None:
|
||||||
"""Закрывает окно добавления пользователя через тулбар."""
|
"""Закрывает окно добавления пользователя через тулбар."""
|
||||||
|
|
||||||
self.close_modal_window_by_toolbar_button("add_local_user")
|
self.close_modal_window_by_toolbar_button("add_user")
|
||||||
|
|
||||||
def close_edit_user_window(self, title: str) -> None:
|
def close_edit_user_window(self, title: str) -> None:
|
||||||
"""Закрывает окно редактирования пользователя.
|
"""Закрывает окно редактирования пользователя.
|
||||||
|
|
@ -282,8 +262,8 @@ class UsersTab(BasePage):
|
||||||
self.toolbar.click_button("add_user")
|
self.toolbar.click_button("add_user")
|
||||||
self.page.wait_for_timeout(700)
|
self.page.wait_for_timeout(700)
|
||||||
|
|
||||||
self.add_modal_window("add_local_user", "")
|
self.add_modal_window("add_user", "")
|
||||||
self.get_modal_window("add_local_user").check_by_window_title()
|
self.get_modal_window("add_user").check_by_window_title()
|
||||||
|
|
||||||
def open_edit_user_page_by_index(self, row_index: int) -> tuple:
|
def open_edit_user_page_by_index(self, row_index: int) -> tuple:
|
||||||
"""Открывает окно редактирования по индексу строки.
|
"""Открывает окно редактирования по индексу строки.
|
||||||
|
|
@ -366,38 +346,11 @@ class UsersTab(BasePage):
|
||||||
|
|
||||||
return new_password
|
return new_password
|
||||||
|
|
||||||
def transform_to_add_AD_user_window(self):
|
|
||||||
"""Трансформирует модальное окно добавления локального пользователя
|
|
||||||
в окно добавления пользователя Active Directory с помощью нажатия
|
|
||||||
чек-бокса Active Directory.
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.get_modal_window("add_local_user").check_active_directory_checkbox()
|
|
||||||
modal_window = self.modal_windows.get("add_AD_user")
|
|
||||||
if modal_window is None:
|
|
||||||
self.add_modal_window("add_AD_user", "")
|
|
||||||
|
|
||||||
def transform_to_add_user_window(self):
|
|
||||||
"""Трансформирует модальное окно добавления пользователя Active Directory
|
|
||||||
в окно добавления локального пользователя с помощью снятия отметки с
|
|
||||||
чек-бокса Active Directory.
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.get_modal_window("add_AD_user").uncheck_active_directory_checkbox()
|
|
||||||
modal_window = self.modal_windows.get("add_local_user")
|
|
||||||
if modal_window is None:
|
|
||||||
self.add_modal_window("add_local_user", "")
|
|
||||||
|
|
||||||
# Проверки:
|
# Проверки:
|
||||||
def check_add_AD_user_window_content(self) -> None:
|
|
||||||
"""Проверяет содержимое окна добавления пользователя через Active Directory."""
|
|
||||||
|
|
||||||
self.get_modal_window("add_AD_user").check_content()
|
|
||||||
|
|
||||||
def check_add_user_window_content(self) -> None:
|
def check_add_user_window_content(self) -> None:
|
||||||
"""Проверяет содержимое окна добавления локального пользователя."""
|
"""Проверяет содержимое окна добавления локального пользователя."""
|
||||||
|
|
||||||
self.get_modal_window("add_local_user").check_content()
|
self.get_modal_window("add_user").check_content()
|
||||||
|
|
||||||
def check_edit_user_window_content(self, user_name: str, role: str) -> None:
|
def check_edit_user_window_content(self, user_name: str, role: str) -> None:
|
||||||
"""Проверяет содержимое окна редактирования.
|
"""Проверяет содержимое окна редактирования.
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,9 @@
|
||||||
Содержит тесты для проверки функциональности
|
Содержит тесты для проверки функциональности
|
||||||
работы с пользователями системы.
|
работы с пользователями системы.
|
||||||
"""
|
"""
|
||||||
import pytest
|
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
import pytest
|
||||||
from playwright.sync_api import Page
|
from playwright.sync_api import Page
|
||||||
from pages.users_tab import UsersTab
|
from pages.users_tab import UsersTab
|
||||||
from pages.main_page import MainPage
|
from pages.main_page import MainPage
|
||||||
|
|
@ -18,7 +19,8 @@ class TestUsersTabAddUser:
|
||||||
1. test_add_user_window_content: Проверяет содержимое окна добавления пользователя
|
1. test_add_user_window_content: Проверяет содержимое окна добавления пользователя
|
||||||
2. test_add_user_window_close_buttons: Проверяет кнопки закрытия окна добавления
|
2. test_add_user_window_close_buttons: Проверяет кнопки закрытия окна добавления
|
||||||
3. test_add_local_user: Проверяет добавление локального пользователя
|
3. test_add_local_user: Проверяет добавление локального пользователя
|
||||||
4. test_add_AD_user: Проверяет добавление пользователя Active Directory
|
4. test_add_keycloack_user: Проверяет добавление пользователя keycloack
|
||||||
|
5. test_add_ldap_user: Проверяет добавление пользователя LDAP
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@pytest.fixture(scope="function", autouse=True)
|
@pytest.fixture(scope="function", autouse=True)
|
||||||
|
|
@ -44,6 +46,7 @@ class TestUsersTabAddUser:
|
||||||
|
|
||||||
# Выход из системы текущего пользователя
|
# Выход из системы текущего пользователя
|
||||||
mp = MainPage(browser)
|
mp = MainPage(browser)
|
||||||
|
browser.wait_for_timeout(1000)
|
||||||
mp.do_logout()
|
mp.do_logout()
|
||||||
|
|
||||||
# Авторизация администратором для очистки
|
# Авторизация администратором для очистки
|
||||||
|
|
@ -61,7 +64,7 @@ class TestUsersTabAddUser:
|
||||||
ut = UsersTab(browser)
|
ut = UsersTab(browser)
|
||||||
|
|
||||||
# Удаляем тестовых пользователей
|
# Удаляем тестовых пользователей
|
||||||
test_users = ["TestUser", "TestUserAD"]
|
test_users = ["TestUser", "TestUserLDAP", "TestUserKeycloack"]
|
||||||
|
|
||||||
for user_name in test_users:
|
for user_name in test_users:
|
||||||
# Проверяем существует ли пользователь и удаляем его
|
# Проверяем существует ли пользователь и удаляем его
|
||||||
|
|
@ -83,11 +86,6 @@ class TestUsersTabAddUser:
|
||||||
ut.open_add_user_window()
|
ut.open_add_user_window()
|
||||||
ut.check_add_user_window_content()
|
ut.check_add_user_window_content()
|
||||||
|
|
||||||
# skip as unsupported
|
|
||||||
# ut.transform_to_add_AD_user_window()
|
|
||||||
# ut.check_add_AD_user_window_content()
|
|
||||||
# ut.close_add_AD_user_window()
|
|
||||||
|
|
||||||
ut.close_add_user_window()
|
ut.close_add_user_window()
|
||||||
|
|
||||||
# @pytest.mark.develop
|
# @pytest.mark.develop
|
||||||
|
|
@ -107,15 +105,6 @@ class TestUsersTabAddUser:
|
||||||
ut.open_add_user_window()
|
ut.open_add_user_window()
|
||||||
ut.close_add_user_window()
|
ut.close_add_user_window()
|
||||||
|
|
||||||
# skip as unsupported
|
|
||||||
# ut.open_add_user_window()
|
|
||||||
# ut.transform_to_add_AD_user_window()
|
|
||||||
# ut.close_add_AD_user_window_by_toolbar_button()
|
|
||||||
|
|
||||||
# ut.open_add_user_window()
|
|
||||||
# ut.transform_to_add_AD_user_window()
|
|
||||||
# ut.close_add_AD_user_window()
|
|
||||||
|
|
||||||
# @pytest.mark.develop
|
# @pytest.mark.develop
|
||||||
def test_add_local_user(self, browser: Page, cleanup_users: None) -> None:
|
def test_add_local_user(self, browser: Page, cleanup_users: None) -> None:
|
||||||
"""Проверяет добавление локального пользователя.
|
"""Проверяет добавление локального пользователя.
|
||||||
|
|
@ -129,8 +118,21 @@ class TestUsersTabAddUser:
|
||||||
self._add_user(browser, user_data)
|
self._add_user(browser, user_data)
|
||||||
|
|
||||||
# @pytest.mark.develop
|
# @pytest.mark.develop
|
||||||
@pytest.mark.skip(reason="This test is temporarily disabled as test unsupported feature")
|
def test_add_keycloack_user(self, browser: Page, cleanup_users: None) -> None:
|
||||||
def test_add_AD_user(self, browser: Page, cleanup_users: None) -> None:
|
"""Проверяет добавление пользователя keycloack.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
browser: Экземпляр страницы Playwright.
|
||||||
|
cleanup_users: Фикстура для автоматического удаления пользователя после теста.
|
||||||
|
"""
|
||||||
|
|
||||||
|
user_data: Dict[str, str] = {"name": "TestUserKeycloack", "auth_type": "keycloack",
|
||||||
|
"role": "Администратор", "password": "987654321efgj"}
|
||||||
|
self._add_user(browser, user_data)
|
||||||
|
|
||||||
|
# @pytest.mark.develop
|
||||||
|
# @pytest.mark.skip(reason="This test is temporarily disabled as test unsupported feature")
|
||||||
|
def test_add_ldap_user(self, browser: Page, cleanup_users: None) -> None:
|
||||||
"""Проверяет добавление пользователя Active Directory.
|
"""Проверяет добавление пользователя Active Directory.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|
@ -139,10 +141,12 @@ class TestUsersTabAddUser:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
user_data: Dict[str, str] = {
|
user_data: Dict[str, str] = {
|
||||||
"auth_type": "active_directory",
|
"auth_type": "LDAP",
|
||||||
"group": "NMS_tester",
|
"group": "NMS_tester",
|
||||||
"name_AD": "tester1", # Выбор из списка "Пользователи AD"
|
# Выбор из списка "Пользователи AD"
|
||||||
"name": "TestUserAD", # Ручной ввод в поле "Имя"
|
"name_ldap": "tester1",
|
||||||
|
# Ручной ввод в поле "Имя"
|
||||||
|
"name": "TestUserLDAP",
|
||||||
"role": "Администратор"
|
"role": "Администратор"
|
||||||
}
|
}
|
||||||
self._add_user(browser, user_data)
|
self._add_user(browser, user_data)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue