2024-08-07 16:19:18 +00:00
|
|
|
from functools import wraps
|
|
|
|
|
|
|
|
|
2023-09-01 11:18:04 +00:00
|
|
|
def close_exists(element):
|
|
|
|
def _wrapper(method_to_decorate):
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
if element.is_visible:
|
|
|
|
element.close()
|
|
|
|
return method_to_decorate(*args, **kwargs)
|
|
|
|
|
|
|
|
return wrapper
|
|
|
|
|
2023-10-09 17:04:29 +00:00
|
|
|
return _wrapper
|
2024-08-07 16:19:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
def handle_settings_opening(view_class, menu_item):
|
|
|
|
def open_settings_decorator(func):
|
|
|
|
@wraps(func)
|
|
|
|
def wrapper(self, click_attempts=2):
|
|
|
|
self._open_settings(menu_item)
|
|
|
|
try:
|
|
|
|
return func(self)
|
|
|
|
except (LookupError, AssertionError) as ex:
|
|
|
|
if click_attempts:
|
|
|
|
|
|
|
|
return func(self, click_attempts - 1)
|
|
|
|
else:
|
|
|
|
raise ex
|
|
|
|
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
return open_settings_decorator
|