fix: 'click' globlal identity
This commit is contained in:
@@ -11,6 +11,7 @@ from selenium.common.exceptions import StaleElementReferenceException, TimeoutEx
|
|||||||
|
|
||||||
driver: WebDriver|None = None
|
driver: WebDriver|None = None
|
||||||
attempts, timeout, interval = int(), float(), float()
|
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):
|
def until(condition: typing.Callable[[WebDriver], bool], watch=True):
|
||||||
try:
|
try:
|
||||||
@@ -46,11 +47,10 @@ def locate(selector: str, wait=True, condition=True) -> WebElement:
|
|||||||
|
|
||||||
def click(selector: str|WebElement, wait=True, condition=False):
|
def click(selector: str|WebElement, wait=True, condition=False):
|
||||||
predicate = None if condition is None else condition or EC.element_to_be_clickable
|
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
|
error = False
|
||||||
|
|
||||||
|
element = locate(selector, wait, predicate) if isinstance(selector, str) else selector
|
||||||
|
counter = lambda: int(element.get_attribute(identity) or 0)
|
||||||
value = counter()
|
value = counter()
|
||||||
driver.execute_script("arguments[0].addEventListener('click', () => arguments[0].setAttribute(arguments[1], arguments[2] + 1));", element, identity, value)
|
driver.execute_script("arguments[0].addEventListener('click', () => arguments[0].setAttribute(arguments[1], arguments[2] + 1));", element, identity, value)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user