-
Notifications
You must be signed in to change notification settings - Fork 837
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Opt: move retry of input to input.py
- Loading branch information
Showing
2 changed files
with
16 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
from module.device.method.uiautomator_2 import Uiautomator2 | ||
from module.logger import logger | ||
|
||
|
||
class Input(Uiautomator2): | ||
def text_input_and_confirm(self, text: str, clear: bool=False): | ||
self.u2_send_keys(text=text, clear=clear) | ||
self.u2_send_action(6) | ||
for fail_count in range(3): | ||
try: | ||
self.u2_send_keys(text=text, clear=clear) | ||
self.u2_send_action(6) | ||
break | ||
except EnvironmentError as e: | ||
if fail_count >= 2: | ||
raise e | ||
logger.exception(str(e) + f'Retrying {fail_count + 1}/3') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters