2023-11-30 22:32:06 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import allure
|
|
|
|
|
|
|
|
import configs
|
|
|
|
import driver
|
|
|
|
from gui.elements.object import QObject
|
|
|
|
|
2023-12-01 13:58:22 +00:00
|
|
|
LOG = logging.getLogger(__name__)
|
2023-11-30 22:32:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TextEdit(QObject):
|
|
|
|
|
|
|
|
@property
|
|
|
|
@allure.step('Get current text {0}')
|
|
|
|
def text(self) -> str:
|
|
|
|
return str(self.object.text)
|
|
|
|
|
|
|
|
@text.setter
|
|
|
|
@allure.step('Type text {1} {0}')
|
|
|
|
def text(self, value: str):
|
2024-10-24 15:45:38 +00:00
|
|
|
if self.text:
|
|
|
|
self.clear()
|
2023-11-30 22:32:06 +00:00
|
|
|
self.type_text(value)
|
|
|
|
assert driver.waitFor(lambda: self.text == value, configs.timeouts.UI_LOAD_TIMEOUT_MSEC), \
|
|
|
|
f'Type text failed, value in field: "{self.text}", expected: {value}'
|
|
|
|
|
|
|
|
@allure.step('Type: {1} in {0}')
|
|
|
|
def type_text(self, value: str):
|
|
|
|
driver.type(self.object, value)
|
2023-12-04 18:16:52 +00:00
|
|
|
LOG.info('%s: value changed to "%s"', self, value)
|
2023-11-30 22:32:06 +00:00
|
|
|
return self
|
|
|
|
|
|
|
|
@allure.step('Clear {0}')
|
|
|
|
def clear(self, verify: bool = True):
|
|
|
|
self.object.clear()
|
|
|
|
if verify:
|
|
|
|
assert driver.waitFor(lambda: not self.text), \
|
|
|
|
f'Clear text field failed, value in field: "{self.text}"'
|
2023-12-04 18:16:52 +00:00
|
|
|
LOG.info('%s: cleared', self)
|
2023-11-30 22:32:06 +00:00
|
|
|
return self
|