import pytest from pages.login_page import LoginPage from pages.main_page import MainPage from pages.configuration_page import ConfigurationPage from pages.users_tab import UsersTab class TestUsersTab: def test_users_tab_content(self, browser): lp = LoginPage(browser) lp.do_login() # we are on main page mp = MainPage(browser) # check navigation panel presence mp.should_be_navigation_panel() # click to Configuration button in main navigation panel mp.click_main_navigation_panel_item("configuration") # we are on configuration page cp = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp.click_configuration_navigation_panel_item("users") # users tab has been opened ut = UsersTab(browser) # check users work area ut.should_be_users_work_area() def test_users_tab_toolbar_buttons(self, browser): lp = LoginPage(browser) lp.do_login() # we are on main page mp = MainPage(browser) # check navigation panel presence mp.should_be_navigation_panel() # click to Configuration button in main navigation panel mp.click_main_navigation_panel_item("configuration") # we are on configuration page cp = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp.click_configuration_navigation_panel_item("users") # users tab has been opened ut = UsersTab(browser) ut.should_be_users_page_toolbar_buttons() def test_add_user_window_content(self, browser): lp = LoginPage(browser) lp.do_login() # we are on main page mp = MainPage(browser) # check navigation panel presence mp.should_be_navigation_panel() # click to Configuration button in main navigation panel mp.click_main_navigation_panel_item("configuration") # we are on configuration page cp = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp.click_configuration_navigation_panel_item("users") # users tab has been opened ut = UsersTab(browser) # open add new user page ut.open_add_user_page() # check add user work area ut.should_be_add_user_work_area() def test_edit_user_window_content(self, browser): lp = LoginPage(browser) lp.do_login() # we are on main page mp = MainPage(browser) # check navigation panel presence mp.should_be_navigation_panel() # click to Configuration button in main navigation panel mp.click_main_navigation_panel_item("configuration") # we are on configuration page cp = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp.click_configuration_navigation_panel_item("users") # users tab has been opened ut = UsersTab(browser) # open edit user page user_name, role = ut.open_edit_user_page_by_index(0) # check edit user work area ut.should_be_edit_user_work_area(user_name, role) def test_edit_user_window_close_buttons(self, browser): lp = LoginPage(browser) lp.do_login() # we are on main page mp = MainPage(browser) # check navigation panel presence mp.should_be_navigation_panel() # click to Configuration button in main navigation panel mp.click_main_navigation_panel_item("configuration") # we are on configuration page cp = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp.click_configuration_navigation_panel_item("users") # users tab has been opened ut = UsersTab(browser) # open edit user page user_name, role = ut.open_edit_user_page_by_index(0) ut.close_user_window_by_toolbar_button(user_name) # open edit user page user_name, role = ut.open_edit_user_page_by_index(0) ut.close_user_window(user_name) def test_add_and_delete_user(self, browser): user_data = {"name": "User", "role": "Администратор", "password": "admin"} lp = LoginPage(browser) lp.do_login() # we are on main page mp = MainPage(browser) # check navigation panel presence mp.should_be_navigation_panel() # click to Configuration button in main navigation panel mp.click_main_navigation_panel_item("configuration") # we are on configuration page cp = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp.click_configuration_navigation_panel_item("users") # users tab has been opened ut = UsersTab(browser) # open add new user page ut.open_add_user_page() # create new user ut.add_new_user(user_data) # click to Users button in configuration navigation panel to update users list (two times is bug?) cp.click_configuration_navigation_panel_item("users") cp.click_configuration_navigation_panel_item("users") # check that new user has been added ut.should_be_user_in_table(user_data["name"], user_data["role"]) # open edit user page and delete user ut.open_edit_user_page_by_name(user_data["name"], user_data["role"]) ut.delete_user() # click to Users button in configuration navigation panel to update users list (two times is bug?) cp.click_configuration_navigation_panel_item("users") cp.click_configuration_navigation_panel_item("users") # check user abcense in users list ut.should_not_be_user_in_table(user_data["name"], user_data["role"]) def test_reset_password(self, browser): user_data = {"name": "autoadmin", "role": "Администратор", "password": "12345"} lp = LoginPage(browser) lp.do_login() # we are on main page mp = MainPage(browser) # check navigation panel presence mp.should_be_navigation_panel() # click to Configuration button in main navigation panel mp.click_main_navigation_panel_item("configuration") # we are on configuration page cp = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp.click_configuration_navigation_panel_item("users") # users tab has been opened ut = UsersTab(browser) # open add new user page ut.open_add_user_page() # create new user ut.add_new_user(user_data) # click to Users button in configuration navigation panel to update users list (two times is bug?) cp.click_configuration_navigation_panel_item("users") cp.click_configuration_navigation_panel_item("users") # check that new user has been added ut.should_be_user_in_table(user_data["name"], user_data["role"]) # open edit user page ut.open_edit_user_page_by_name(user_data["name"], user_data["role"]) new_password = ut.reset_password() if len(new_password) == 0: assert False, "Unsuccessful password reset" new_lp = LoginPage(browser) new_lp.do_login(username=user_data["name"], password=new_password) # we are on main page new_mp = MainPage(browser) # do logout new_mp.do_logout() lp_1 = LoginPage(browser) lp_1.do_login() # we are on main page mp_1 = MainPage(browser) # click to Configuration button in main navigation panel mp_1.click_main_navigation_panel_item("configuration") # we are on configuration page cp_1 = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp_1.click_configuration_navigation_panel_item("users") # users tab has been opened ut_1 = UsersTab(browser) # open edit user page and delete user ut_1.open_edit_user_page_by_name(user_data["name"], user_data["role"]) ut_1.delete_user() # click to Users button in configuration navigation panel to update users list (two times is bug?) cp_1.click_configuration_navigation_panel_item("users") cp_1.click_configuration_navigation_panel_item("users") # check user abcense in users list ut_1.should_not_be_user_in_table(user_data["name"], user_data["role"]) def test_edit_user_role(self, browser): user_data = {"name": "autooperator", "role": "Оператор", "password": "auto123@"} lp = LoginPage(browser) lp.do_login() # we are on main page mp = MainPage(browser) # check navigation panel presence mp.should_be_navigation_panel() # click to Configuration button in main navigation panel mp.click_main_navigation_panel_item("configuration") # we are on configuration page cp = ConfigurationPage(browser) # click to Users button in configuration navigation panel cp.click_configuration_navigation_panel_item("users") # users tab has been opened ut = UsersTab(browser) # open add new user page ut.open_add_user_page() # create new user ut.add_new_user(user_data) # click to Users button in configuration navigation panel to update users list (two times is bug?) cp.click_configuration_navigation_panel_item("users") cp.click_configuration_navigation_panel_item("users") # check that new user has been added ut.should_be_user_in_table(user_data["name"], user_data["role"]) # open edit user page and delete user ut.open_edit_user_page_by_name(user_data["name"], user_data["role"]) new_user_data = {} new_user_data["role"] = "Контактное лицо" ut.edit_user(new_user_data) # click to Users button in configuration navigation panel to update users list (two times is bug?) cp.click_configuration_navigation_panel_item("users") cp.click_configuration_navigation_panel_item("users") # check that new user has been added ut.should_be_user_in_table(user_data["name"], new_user_data["role"]) # open edit user page and delete user ut.open_edit_user_page_by_name(user_data["name"], new_user_data["role"]) ut.delete_user() # click to Users button in configuration navigation panel to update users list (two times is bug?) cp.click_configuration_navigation_panel_item("users") cp.click_configuration_navigation_panel_item("users") # check user abcense in users list ut.should_not_be_user_in_table(user_data["name"], new_user_data["role"])