fix chain click bug (#1019)
This commit is contained in:
@@ -355,8 +355,8 @@ class InputActionOnSelect2Dropdown(SkyvernException):
|
|||||||
|
|
||||||
|
|
||||||
class FailToClick(SkyvernException):
|
class FailToClick(SkyvernException):
|
||||||
def __init__(self, element_id: str):
|
def __init__(self, element_id: str, anchor: str = "self"):
|
||||||
super().__init__(f"Failed to click. element_id={element_id}")
|
super().__init__(f"Failed to click({anchor}). element_id={element_id}")
|
||||||
|
|
||||||
|
|
||||||
class FailToSelectByLabel(SkyvernException):
|
class FailToSelectByLabel(SkyvernException):
|
||||||
|
|||||||
@@ -1060,9 +1060,33 @@ async def chain_click(
|
|||||||
javascript_triggered=javascript_triggered,
|
javascript_triggered=javascript_triggered,
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
if await is_input_element(locator):
|
|
||||||
|
if skyvern_element.get_tag_name() == "label":
|
||||||
|
LOG.info(
|
||||||
|
"Chain click: it's a label element. going to try for-click",
|
||||||
|
task_id=task.task_id,
|
||||||
|
action=action,
|
||||||
|
locator=locator,
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
if bound_element := await skyvern_element.find_label_for(
|
||||||
|
dom=DomUtil(scraped_page=scraped_page, page=page)
|
||||||
|
):
|
||||||
|
await bound_element.get_locator().click(timeout=timeout)
|
||||||
|
action_results.append(ActionSuccess())
|
||||||
|
return action_results
|
||||||
|
except Exception:
|
||||||
|
action_results.append(
|
||||||
|
ActionFailure(
|
||||||
|
FailToClick(action.element_id, anchor="for"),
|
||||||
|
javascript_triggered=javascript_triggered,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if skyvern_element.get_tag_name() == InteractiveElement.INPUT:
|
||||||
LOG.info(
|
LOG.info(
|
||||||
"Chain click: it's an input element. going to try sibling click",
|
"Chain click: it's an input element. going to try sibling click",
|
||||||
|
task_id=task.task_id,
|
||||||
action=action,
|
action=action,
|
||||||
locator=locator,
|
locator=locator,
|
||||||
)
|
)
|
||||||
@@ -1100,7 +1124,7 @@ async def chain_click(
|
|||||||
)
|
)
|
||||||
action_results.append(
|
action_results.append(
|
||||||
ActionFailure(
|
ActionFailure(
|
||||||
FailToClick(action.element_id),
|
FailToClick(action.element_id, anchor="parent"),
|
||||||
javascript_triggered=javascript_triggered,
|
javascript_triggered=javascript_triggered,
|
||||||
interacted_with_parent=True,
|
interacted_with_parent=True,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user