2023-08-04 18:27:03 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
import allure
|
2024-08-27 07:34:00 +00:00
|
|
|
import pyperclip
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
import configs
|
|
|
|
import constants
|
|
|
|
import driver
|
|
|
|
from gui.components.profile_popup import ProfilePopup
|
2023-10-06 08:33:42 +00:00
|
|
|
from gui.elements.button import Button
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
from gui.elements.text_label import TextLabel
|
2024-02-13 09:04:24 +00:00
|
|
|
from gui.objects_map import names
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
|
2023-12-13 08:20:56 +00:00
|
|
|
class OnlineIdentifier(QObject):
|
2023-08-04 18:27:03 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
2024-02-13 09:04:24 +00:00
|
|
|
super(OnlineIdentifier, self).__init__(names.onlineIdentifierProfileHeader)
|
|
|
|
self._always_active_button = Button(names.userContextmenu_AlwaysActiveButton)
|
|
|
|
self._inactive_button = Button(names.userContextmenu_InActiveButton)
|
|
|
|
self._automatic_button = Button(names.userContextmenu_AutomaticButton)
|
|
|
|
self._view_my_profile_button = Button(names.userContextMenu_ViewMyProfileAction)
|
2024-08-27 07:34:00 +00:00
|
|
|
self._copy_link_to_profile = QObject(names.userContextMenu_CopyLinkToProfile)
|
2024-02-13 09:04:24 +00:00
|
|
|
self._user_name_text_label = TextLabel(names.userLabel_StyledText)
|
|
|
|
self._identicon_ring = QObject(names.o_StatusIdenticonRing)
|
2023-08-04 18:27:03 +00:00
|
|
|
|
2023-12-13 08:20:56 +00:00
|
|
|
@allure.step('Wait until appears {0}')
|
|
|
|
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
|
|
|
|
driver.waitFor(lambda: self._view_my_profile_button.is_visible, timeout_msec)
|
|
|
|
return self
|
|
|
|
|
2023-08-04 18:27:03 +00:00
|
|
|
@property
|
|
|
|
@allure.step('Get user name')
|
2023-12-21 17:44:15 +00:00
|
|
|
def get_user_name(self) -> str:
|
2023-08-04 18:27:03 +00:00
|
|
|
return self._user_name_text_label.text
|
|
|
|
|
|
|
|
@allure.step('Set user state online')
|
|
|
|
def set_user_state_online(self):
|
|
|
|
self._always_active_button.click()
|
|
|
|
self.wait_until_hidden()
|
|
|
|
|
|
|
|
@allure.step('Set user state offline')
|
|
|
|
def set_user_state_offline(self):
|
|
|
|
self._inactive_button.click()
|
|
|
|
self.wait_until_hidden()
|
|
|
|
|
|
|
|
@allure.step('Set user automatic state')
|
|
|
|
def set_user_automatic_state(self):
|
|
|
|
self._automatic_button.click()
|
|
|
|
self.wait_until_hidden()
|
|
|
|
|
2023-12-12 15:43:22 +00:00
|
|
|
@allure.step('Open Profile popup from online identifier')
|
2024-05-31 14:00:33 +00:00
|
|
|
def open_profile_popup_from_online_identifier(self) -> ProfilePopup:
|
2023-08-04 18:27:03 +00:00
|
|
|
self._view_my_profile_button.click()
|
2024-08-27 07:34:00 +00:00
|
|
|
return ProfilePopup().wait_until_appears()
|
|
|
|
|
|
|
|
@allure.step('Copy link to profile from online identifier')
|
|
|
|
def copy_link_to_profile(self) -> str:
|
|
|
|
self._copy_link_to_profile.click()
|
|
|
|
link = str(pyperclip.paste())
|
|
|
|
return link
|