diff --git a/components/base_component.py b/components/base_component.py index 83f92a9..778144c 100644 --- a/components/base_component.py +++ b/components/base_component.py @@ -51,14 +51,14 @@ class BaseComponent: fields_locators = {} - layouts = container_locator.locator("div.layout") + layouts = container_locator.locator("div.layout > div.flex").locator("..") for i in range(layouts.count()): layout = layouts.nth(i) flex_containers = layout.locator("div.flex") # Обрабатываем пары контейнеров - for j in range(0, flex_containers.count() - 1): + for j in range(0, flex_containers.count() - 1, 2): label_container = flex_containers.nth(j) input_container = flex_containers.nth(j + 1) @@ -71,9 +71,11 @@ class BaseComponent: has_input = input_container.locator( "input, textarea, select" ).count() > 0 + + not_found = fields_locators.get(label_text) is None - if has_input: - fields_locators[label_text] = input_container + if has_input and not_found: + fields_locators[label_text] = input_container return fields_locators diff --git a/components/dropdown_list_component.py b/components/dropdown_list_component.py index 9df5267..37216ba 100644 --- a/components/dropdown_list_component.py +++ b/components/dropdown_list_component.py @@ -82,7 +82,12 @@ class DropdownList(BaseComponent): loc = self.get_locator(locator) 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, value_locator: str | Locator = None) -> str: diff --git a/components/eventbar_component.py b/components/eventbar_component.py index 68d8d7f..d65bb69 100644 --- a/components/eventbar_component.py +++ b/components/eventbar_component.py @@ -158,12 +158,12 @@ class EventPanelComponent(BaseComponent): """Возвращает текущее положение панели событий относительно страницы: "top", "center","bottom".""" style_attr = self.page.locator(EventPanelLocators.AREA_EVENTS).get_attribute("style") - position = "bottom" + position = "top" if style_attr.find("display: none;") == -1: - height = style_attr.replace("height: ","").replace(";", "") + height = style_attr.replace("position: relative;","").replace("height: ","").replace(";", "").lstrip() if height == "100%": - position = "top" + position = "bottom" else: position = "center" diff --git a/components_derived/modal_add_user.py b/components_derived/modal_add_user.py index be3fb86..9472e62 100644 --- a/components_derived/modal_add_user.py +++ b/components_derived/modal_add_user.py @@ -49,11 +49,12 @@ class AddUserModalWindow(ModalWindowComponent): self.add_toolbar_button(locator_button_toolbar_close, "close") elements_locators = self.get_input_fields_locators(page.locator(input_form_locator)) + # print(elements_locators) # Поле Тип авторизации - loc = elements_locators.get("Тип авторизации") - if loc: - auth_type_selector = SelectionBarComponent(page, loc.get_by_role("combobox")) + auth_type_loc = elements_locators.get("Тип авторизации") + if auth_type_loc: + auth_type_selector = SelectionBarComponent(page, auth_type_loc.get_by_role("combobox").first) self.add_content_item("auth_type_selector", auth_type_selector) # Поле Имя @@ -352,13 +353,12 @@ class AddUserModalWindow(ModalWindowComponent): Форма для создания keycloack пользователя имеет тот же набор полей. """ - expected_auth_types = ['local', 'LDAP', 'keycloack'] + expected_auth_types = ['local', 'LDAP', 'keycloak'] 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() @@ -387,7 +387,7 @@ class AddUserModalWindow(ModalWindowComponent): continue assert current_auth_type == 'local', "Default Auth Type value should be 'local'" - actual_auth_types = item.get_available_options(items_locator) + actual_auth_types = item.get_available_options() 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": diff --git a/components_derived/modal_send_test_email.py b/components_derived/modal_send_test_email.py index cd2de70..576e22f 100644 --- a/components_derived/modal_send_test_email.py +++ b/components_derived/modal_send_test_email.py @@ -39,8 +39,7 @@ class SendTestEmailModalWindow(ModalWindowComponent): self.add_toolbar_button(toolbar_button_close_locator, "close") # Поле ввода адреса - elements_locators = self.get_input_fields_locators(window_locator) - loc = elements_locators.get("E-mail").locator("div.v-text-field__slot > input") + loc = window_locator.locator("//input[@data-testid='E_MAIL_CARD__text-field_text__email']") email_input = TextInput(page, loc, "email_input") self.add_content_item("email_input", email_input) diff --git a/components_derived/selection_bar_component.py b/components_derived/selection_bar_component.py index 9cb81a2..686a85e 100644 --- a/components_derived/selection_bar_component.py +++ b/components_derived/selection_bar_component.py @@ -44,6 +44,7 @@ class SelectionBarComponent(BaseComponent): # При нажатии на панель появляется выпадающий список с параметрами фильтрации для выбора self.selected_values_list = DropdownList(self.page) + print(self.selection_bar_locator) # Действия: def clear_selections(self) -> None: @@ -75,7 +76,7 @@ class SelectionBarComponent(BaseComponent): options = self.selected_values_list.get_item_names( SelectionBarLocators.LIST_ITEMS ) - + # Закрываем список (кликаем вне его) self.page.mouse.click(10, 10) self.wait_for_timeout(500) diff --git a/locators/event_panel_locators.py b/locators/event_panel_locators.py index 10acce4..2927301 100644 --- a/locators/event_panel_locators.py +++ b/locators/event_panel_locators.py @@ -22,7 +22,7 @@ class EventPanelLocators: CONTAINER_SYSTEM_LOG_EVENTS (str): контейнера с событиями Системного журнала. """ - AREA_EVENTS = "#app > div.application--wrap > div > div:nth-child(3)" + AREA_EVENTS = "#app > div.application--wrap > div > div:nth-child(1)" BUTTON_EXPAND_LESS = "//button[contains(@data-testid, 'BASELINE__btn__toolbar_close')]" BUTTON_EXPAND_MORE = "//button[contains(@data-testid, 'BASELINE__btn__toolbar_open')]" diff --git a/locators/selection_bar_locators.py b/locators/selection_bar_locators.py index 0786f25..001e994 100644 --- a/locators/selection_bar_locators.py +++ b/locators/selection_bar_locators.py @@ -20,7 +20,7 @@ class SelectionBarLocators: # Локаторы для элементов выпадающего списка LISTBOX = "//div[@role='list']" - LIST_ITEMS = "//div[@role='list']//div[@role='listitem']" + LIST_ITEMS = "//div[contains(@class, 'menuable__content__active')]//div[@role='list']//div[@role='listitem']" # Локатор для родительского контейнера поля ввода INPUT_PARENT_CONTAINER = "xpath=./ancestor::div[contains(@class, 'v-input')]" diff --git a/tests/e2e/users/test_add_user.py b/tests/e2e/users/test_add_user.py index c82a037..b66b2b5 100644 --- a/tests/e2e/users/test_add_user.py +++ b/tests/e2e/users/test_add_user.py @@ -83,11 +83,6 @@ class TestUsersTabAddUser: ut.open_add_user_window() 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() # @pytest.mark.develop