diff --git a/src/common/utils/selenium.py b/src/common/utils/selenium.py index 7c3d1b0..7c18a4d 100644 --- a/src/common/utils/selenium.py +++ b/src/common/utils/selenium.py @@ -11,6 +11,7 @@ from selenium.common.exceptions import StaleElementReferenceException, TimeoutEx driver: WebDriver|None = None attempts, timeout, interval = int(), float(), float() +identity = ''.join(random.choices(string.ascii_uppercase + string.digits, k=8)) def until(condition: typing.Callable[[WebDriver], bool], watch=True): try: @@ -46,11 +47,10 @@ def locate(selector: str, wait=True, condition=True) -> WebElement: def click(selector: str|WebElement, wait=True, condition=False): predicate = None if condition is None else condition or EC.element_to_be_clickable - identity = ''.join(random.choices(string.ascii_uppercase + string.digits, k=8)) - element = locate(selector, wait, predicate) if isinstance(selector, str) else selector - counter = lambda: int(element.get_attribute(identity) or 0) error = False + element = locate(selector, wait, predicate) if isinstance(selector, str) else selector + counter = lambda: int(element.get_attribute(identity) or 0) value = counter() driver.execute_script("arguments[0].addEventListener('click', () => arguments[0].setAttribute(arguments[1], arguments[2] + 1));", element, identity, value)