hack input-select select (#772)

This commit is contained in:
LawyZheng
2024-09-04 23:31:47 +08:00
committed by GitHub
parent 069597e52e
commit e515d58e15

View File

@@ -345,6 +345,7 @@ async def handle_input_text_action(
if text is None: if text is None:
return [ActionFailure(FailedToFetchSecret())] return [ActionFailure(FailedToFetchSecret())]
incremental_element: list[dict] = []
# check if it's selectable # check if it's selectable
if skyvern_element.get_tag_name() == InteractiveElement.INPUT: if skyvern_element.get_tag_name() == InteractiveElement.INPUT:
await skyvern_element.scroll_into_view() await skyvern_element.scroll_into_view()
@@ -421,6 +422,7 @@ async def handle_input_text_action(
LOG.warning("Failed to clear the input field", action=action, exc_info=True) LOG.warning("Failed to clear the input field", action=action, exc_info=True)
return [ActionFailure(InvalidElementForTextInput(element_id=action.element_id, tag_name=tag_name))] return [ActionFailure(InvalidElementForTextInput(element_id=action.element_id, tag_name=tag_name))]
try:
# TODO: not sure if this case will trigger auto-completion # TODO: not sure if this case will trigger auto-completion
if tag_name not in COMMON_INPUT_TAGS: if tag_name not in COMMON_INPUT_TAGS:
await skyvern_element.input_fill(text) await skyvern_element.input_fill(text)
@@ -443,6 +445,14 @@ async def handle_input_text_action(
await skyvern_element.input_sequentially(text=text) await skyvern_element.input_sequentially(text=text)
return [ActionSuccess()] return [ActionSuccess()]
finally:
# HACK: force to finish missing auto completion input
if len(incremental_element) > 0:
LOG.debug(
"Trigger input-selection hack, pressing Tab to choose one",
action=action,
)
await skyvern_element.press_key("Tab")
async def handle_upload_file_action( async def handle_upload_file_action(