Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback to input when input selection failed #1393

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading