2024-05-08 06:27:30 +00:00
|
|
|
import allure
|
|
|
|
|
|
|
|
import configs
|
|
|
|
import driver
|
2024-05-17 08:13:33 +00:00
|
|
|
from driver.objects_access import walk_children
|
2024-05-08 06:27:30 +00:00
|
|
|
from gui.components.base_popup import BasePopup
|
|
|
|
from gui.elements.button import Button
|
2024-06-06 07:17:16 +00:00
|
|
|
from gui.elements.object import QObject
|
2024-05-08 06:27:30 +00:00
|
|
|
from gui.elements.text_edit import TextEdit
|
|
|
|
from gui.objects_map import names
|
|
|
|
|
|
|
|
|
|
|
|
class RenameKeypairPopup(BasePopup):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(RenameKeypairPopup, self).__init__()
|
|
|
|
self._rename_text_edit = TextEdit(names.edit_TextEdit)
|
|
|
|
self._save_changes_button = Button(names.save_changes_rename_StatusButton)
|
2024-06-06 07:17:16 +00:00
|
|
|
self._name_input = QObject(names.nameInput_StatusInput)
|
2024-05-08 06:27:30 +00:00
|
|
|
|
|
|
|
@allure.step('Wait until appears {0}')
|
|
|
|
def wait_until_appears(self, timeout_msec: int = configs.timeouts.UI_LOAD_TIMEOUT_MSEC):
|
|
|
|
driver.waitForObjectExists(self._save_changes_button.real_name, timeout_msec)
|
|
|
|
return self
|
|
|
|
|
|
|
|
@allure.step('Rename keypair')
|
|
|
|
def rename_keypair(self, name):
|
2024-05-17 08:13:33 +00:00
|
|
|
for child in walk_children(self.object):
|
|
|
|
if getattr(child, 'id', '') == 'edit':
|
|
|
|
text_edit = TextEdit(real_name=driver.objectMap.realName(child))
|
|
|
|
text_edit.text = name
|
2024-06-06 07:17:16 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
@allure.step('Save changes')
|
|
|
|
def save_changes(self):
|
2024-05-08 06:27:30 +00:00
|
|
|
self._save_changes_button.click()
|
|
|
|
self.wait_until_hidden()
|
2024-06-06 07:17:16 +00:00
|
|
|
|
|
|
|
@allure.step('Get error message')
|
|
|
|
def get_error_message(self) -> str:
|
|
|
|
return str(self._name_input.object.errorMessageCmp.text)
|