43 lines
1.9 KiB
Python
43 lines
1.9 KiB
Python
from pages.base_page import BasePage
|
|
from Locators.main_page import MainPageLocators
|
|
from data.assertions import Assertions
|
|
from playwright.sync_api import Page
|
|
|
|
class MainPage(BasePage):
|
|
def __init__(self, page: Page) -> None:
|
|
super().__init__(page)
|
|
self.assertion = Assertions(page)
|
|
|
|
def should_be_navigation_panel(self):
|
|
self.assertion.check_presence(MainPageLocators.NAVIGATION_PANEL, "Navigation panel is not present")
|
|
|
|
def click_main_navigation_panel_item(self, item_name):
|
|
button_locator = None
|
|
header_locator = None
|
|
|
|
if item_name == "dashboard":
|
|
button_locator = MainPageLocators.NAVIGATION_PANEL_DASHBOARD_BUTTON
|
|
header_locator = MainPageLocators.NAVIGATION_PANEL_DASHBOARD_BUTTON_HEADER
|
|
elif item_name == "topology":
|
|
button_locator = MainPageLocators.NAVIGATION_PANEL_TOPOLOGY_BUTTON
|
|
header_locator = MainPageLocators.NAVIGATION_PANEL_TOPOLOGY_BUTTON_HEADER
|
|
elif item_name == "configuration":
|
|
button_locator = MainPageLocators.NAVIGATION_PANEL_CONFIGURATION_BUTTON
|
|
header_locator = MainPageLocators.NAVIGATION_PANEL_CONFIGURATION_BUTTON_HEADER
|
|
else:
|
|
assert False, "Unsupported main navigation panel item"
|
|
|
|
self.click(button_locator)
|
|
self.assertion.check_URL(item_name, "An unexpected page has been opened")
|
|
self.assertion.check_element_active(header_locator, f"{item_name} button is not active")
|
|
|
|
def do_logout(self):
|
|
self.click(MainPageLocators.CURRENT_USER_BUTTON)
|
|
|
|
self.assertion.check_presence(MainPageLocators.CURRENT_USER_WINDOW, "Window with current user data has not been opened")
|
|
|
|
logout_button_text = "Выйти"
|
|
self.page.get_by_role("button", name=logout_button_text).click()
|
|
|
|
self.assertion.check_URL("login", "An unexpected page has been opened")
|