fix spinbutton issue (#806)
This commit is contained in:
@@ -414,7 +414,7 @@ async def handle_input_text_action(
|
|||||||
|
|
||||||
incremental_element: list[dict] = []
|
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 and not await skyvern_element.is_spinbtn_input():
|
||||||
await skyvern_element.scroll_into_view()
|
await skyvern_element.scroll_into_view()
|
||||||
select_action = SelectOptionAction(
|
select_action = SelectOptionAction(
|
||||||
reasoning=action.reasoning, element_id=skyvern_element.get_id(), option=SelectOption(label=text)
|
reasoning=action.reasoning, element_id=skyvern_element.get_id(), option=SelectOption(label=text)
|
||||||
@@ -483,14 +483,16 @@ async def handle_input_text_action(
|
|||||||
|
|
||||||
# force to move focus back to the element
|
# force to move focus back to the element
|
||||||
await skyvern_element.get_locator().focus(timeout=timeout)
|
await skyvern_element.get_locator().focus(timeout=timeout)
|
||||||
try:
|
# `Locator.clear()` on a spin button could cause the cursor moving away, and never be back
|
||||||
await skyvern_element.input_clear()
|
if not await skyvern_element.is_spinbtn_input():
|
||||||
except TimeoutError:
|
try:
|
||||||
LOG.info("None input tag clear timeout", action=action)
|
await skyvern_element.input_clear()
|
||||||
return [ActionFailure(InvalidElementForTextInput(element_id=action.element_id, tag_name=tag_name))]
|
except TimeoutError:
|
||||||
except Exception:
|
LOG.info("None input tag clear timeout", action=action)
|
||||||
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))]
|
except Exception:
|
||||||
|
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))]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# TODO: not sure if this case will trigger auto-completion
|
# TODO: not sure if this case will trigger auto-completion
|
||||||
|
|||||||
@@ -197,6 +197,22 @@ class SkyvernElement:
|
|||||||
button_type = await self.get_attr("type")
|
button_type = await self.get_attr("type")
|
||||||
return button_type == "radio"
|
return button_type == "radio"
|
||||||
|
|
||||||
|
async def is_spinbtn_input(self) -> bool:
|
||||||
|
"""
|
||||||
|
confirm the element is:
|
||||||
|
1. <input> element
|
||||||
|
2. role=spinbutton
|
||||||
|
|
||||||
|
Usage of <input role="spinbutton">, https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/spinbutton_role
|
||||||
|
"""
|
||||||
|
if self.get_tag_name() != InteractiveElement.INPUT:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if await self.get_attr("role") == "spinbutton":
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def is_interactable(self) -> bool:
|
def is_interactable(self) -> bool:
|
||||||
return self.__static_element.get("interactable", False)
|
return self.__static_element.get("interactable", False)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user