mark readonly element as interactable (#3845)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user