Skip to content

Commit

Permalink
fallback to input when input selection failed (#1393)
Browse files Browse the repository at this point in the history
  • Loading branch information
LawyZheng authored Dec 16, 2024
1 parent 245cd1c commit e2f886d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
7 changes: 7 additions & 0 deletions skyvern/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,10 @@ def __init__(self, reason: str | None, error_type: str | None):
class UnsupportedTaskType(SkyvernException):
def __init__(self, task_type: str):
super().__init__(f"Not supported task type [{task_type}]")


class InteractWithDropdownContainer(SkyvernException):
def __init__(self, element_id: str):
super().__init__(
f"Select on the dropdown container instead of the option, try again with another element. element_id={element_id}"
)
35 changes: 27 additions & 8 deletions skyvern/webeye/actions/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
IllegitComplete,
ImaginaryFileUrl,
InteractWithDisabledElement,
InteractWithDropdownContainer,
InvalidElementForTextInput,
MissingElement,
MissingElementDict,
Expand Down Expand Up @@ -571,15 +572,27 @@ async def handle_input_text_action(
task=task,
target_value=text,
)
if result is not None:
if result is not None and result.success:
return [result]
LOG.info(
"It might not be a selectable auto-completion input, exit the custom selection mode",
task_id=task.task_id,
step_id=step.step_id,
element_id=skyvern_element.get_id(),
action=action,
)

if result is None:
LOG.info(
"It might not be a selectable auto-completion input, exit the custom selection mode",
task_id=task.task_id,
step_id=step.step_id,
element_id=skyvern_element.get_id(),
action=action,
)
else:
LOG.warning(
"Custom selection returned an error, continue to input text",
task_id=task.task_id,
step_id=step.step_id,
element_id=skyvern_element.get_id(),
action=action,
err_msg=result.exception_message,
)

except Exception:
await skyvern_element.scroll_into_view()
LOG.warning(
Expand Down Expand Up @@ -1951,6 +1964,12 @@ async def select_from_dropdown(

try:
selected_element = await SkyvernElement.create_from_incremental(incremental_scraped, element_id)
if await selected_element.get_attr("role") == "listbox":
single_select_result.action_result = ActionFailure(
exception=InteractWithDropdownContainer(element_id=element_id)
)
return single_select_result

await selected_element.scroll_into_view()
await selected_element.get_locator().click(timeout=timeout)
single_select_result.action_result = ActionSuccess()
Expand Down

0 comments on commit e2f886d

Please sign in to comment.