do not clear input when empty (#3114)
This commit is contained in:
@@ -1086,8 +1086,21 @@ async def handle_input_text_action(
|
||||
exc_info=True,
|
||||
)
|
||||
|
||||
# TODO: some elements are supported to use `locator.press_sequentially()` to fill in the data
|
||||
# we need find a better way to detect the attribute in the future
|
||||
class_name: str | None = await skyvern_element.get_attr("class")
|
||||
if class_name and "blinking-cursor" in class_name:
|
||||
if is_totp_value:
|
||||
text = generate_totp_value(task=task, parameter=action.text)
|
||||
await skyvern_element.press_fill(text=text)
|
||||
return [ActionSuccess()]
|
||||
|
||||
# `Locator.clear()` on a spin button could cause the cursor moving away, and never be back
|
||||
if not await skyvern_element.is_spinbtn_input():
|
||||
# run `Locator.clear()` when:
|
||||
# 1. the element is not a spin button
|
||||
# 1.1. the element has a value attribute
|
||||
# 1.2. the element is not common input tag
|
||||
if not await skyvern_element.is_spinbtn_input() and (current_text or (tag_name not in COMMON_INPUT_TAGS)):
|
||||
try:
|
||||
await skyvern_element.input_clear()
|
||||
except TimeoutError:
|
||||
@@ -1095,17 +1108,7 @@ async def handle_input_text_action(
|
||||
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)
|
||||
|
||||
# TODO: some elements are supported to use `locator.press_sequentially()` to fill in the data
|
||||
# we need find a better way to detect the attribute in the future
|
||||
class_name: str | None = await skyvern_element.get_attr("class")
|
||||
if not class_name or "blinking-cursor" not in class_name:
|
||||
return [ActionFailure(InvalidElementForTextInput(element_id=action.element_id, tag_name=tag_name))]
|
||||
|
||||
if is_totp_value:
|
||||
text = generate_totp_value(task=task, parameter=action.text)
|
||||
await skyvern_element.press_fill(text=text)
|
||||
return [ActionSuccess()]
|
||||
return [ActionFailure(InvalidElementForTextInput(element_id=action.element_id, tag_name=tag_name))]
|
||||
|
||||
# wait 2s for blocking element to show up
|
||||
await asyncio.sleep(2)
|
||||
|
||||
Reference in New Issue
Block a user