2023-10-31 11:53:49 +01:00
|
|
|
import logging
|
|
|
|
|
2023-08-04 20:27:03 +02:00
|
|
|
import allure
|
|
|
|
|
|
|
|
import configs
|
|
|
|
import driver
|
2023-10-06 10:33:42 +02:00
|
|
|
from gui.elements.object import QObject
|
2023-08-04 20:27:03 +02:00
|
|
|
|
2023-10-31 11:53:49 +01:00
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
2023-08-04 20:27:03 +02: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):
|
|
|
|
self.clear()
|
|
|
|
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-10-31 11:53:49 +01:00
|
|
|
_logger.info(f'{self}: value changed to "{value}"')
|
2023-08-04 20:27:03 +02:00
|
|
|
return self
|
|
|
|
|
|
|
|
@allure.step('Clear {0}')
|
2023-09-01 18:18:04 +07:00
|
|
|
def clear(self, verify: bool = True):
|
2023-08-04 20:27:03 +02:00
|
|
|
self.object.clear()
|
2023-09-01 18:18:04 +07:00
|
|
|
if verify:
|
|
|
|
assert driver.waitFor(lambda: not self.text), \
|
2023-10-04 16:46:17 +06:00
|
|
|
f'Clear text field failed, value in field: "{self.text}"'
|
2023-10-31 11:53:49 +01:00
|
|
|
_logger.info(f'{self}: cleared')
|
2023-08-04 20:27:03 +02:00
|
|
|
return self
|