mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
Update assert_button_click function in ui/utils.py to handle button click failures
This commit is contained in:
parent
a9dddbcee9
commit
bc077b6253
1 changed files with 7 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from contextlib import suppress
|
||||
from datetime import datetime
|
||||
from logging import error as log_error, exception as log_exception, info as log_info, warning as log_warning
|
||||
from time import sleep
|
||||
from typing import List, Optional, Union
|
||||
|
|
@ -51,6 +52,7 @@ def safe_get_element(
|
|||
|
||||
def assert_button_click(driver, button: Union[str, WebElement], by: str = "xpath"): # type: ignore
|
||||
clicked = False
|
||||
current_date = datetime.now()
|
||||
while not clicked:
|
||||
with suppress(ElementClickInterceptedException):
|
||||
if isinstance(button, str):
|
||||
|
|
@ -67,6 +69,11 @@ def assert_button_click(driver, button: Union[str, WebElement], by: str = "xpath
|
|||
button.click()
|
||||
|
||||
clicked = True
|
||||
|
||||
if (datetime.now() - current_date).seconds > 10:
|
||||
log_error("Button click failed, exiting ...")
|
||||
exit(1)
|
||||
|
||||
return clicked
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue