mark readonly element as interactable (#3845)

This commit is contained in:
LawyZheng
2025-10-29 13:10:21 +08:00
committed by GitHub
parent 49fd5f3c07
commit f6145665c8
5 changed files with 88 additions and 13 deletions

View File

@@ -38,6 +38,7 @@ from skyvern.exceptions import (
IllegitComplete,
ImaginaryFileUrl,
InputToInvisibleElement,
InputToReadonlyElement,
InteractWithDisabledElement,
InteractWithDropdownContainer,
InvalidElementForTextInput,
@@ -1225,6 +1226,17 @@ async def handle_input_text_action(
# force to move focus back to the element
await skyvern_element.get_locator().focus(timeout=timeout)
# check if the element is readonly(some elements will be non-readonly after focused)
if await skyvern_element.is_readonly(dynamic=True):
LOG.warning(
"Try to input text on a readonly element",
task_id=task.task_id,
step_id=step.step_id,
element_id=skyvern_element.get_id(),
action=action,
)
return [ActionFailure(InputToReadonlyElement(element_id=skyvern_element.get_id()))]
# check the phone number format when type=tel and the text is not a secret value
if not is_secret_value and await skyvern_element.get_attr("type") == "tel":
try:
@@ -2939,6 +2951,13 @@ async def select_from_emerging_elements(
if current_text == actual_value:
return ActionSuccess()
if await input_element.is_readonly(dynamic=True):
LOG.warning(
"Try to input text on a readonly element",
element_id=element_id,
)
return ActionFailure(InputToReadonlyElement(element_id=element_id))
await input_element.input_clear()
await input_element.input_sequentially(actual_value)
return ActionSuccess()
@@ -3084,6 +3103,16 @@ async def select_from_dropdown(
single_select_result.action_result = ActionSuccess()
return single_select_result
if await input_element.is_readonly(dynamic=True):
LOG.warning(
"Try to input text on a readonly element",
element_id=element_id,
task_id=task.task_id,
step_id=step.step_id,
)
single_select_result.action_result = ActionFailure(InputToReadonlyElement(element_id=element_id))
return single_select_result
await input_element.input_clear()
await input_element.input_sequentially(actual_value)
single_select_result.action_result = ActionSuccess()