improve dropdown detect (#1927)

This commit is contained in:
Shuchang Zheng
2025-03-11 12:33:09 -07:00
committed by GitHub
parent 14308d4531
commit a572126d61
3 changed files with 7 additions and 4 deletions

View File

@@ -2,7 +2,7 @@ You are performing a {{ "multi-level selection" if select_history else "selectio
You can identify the matching element based on the following guidelines:
1. Select the most suitable element based on the user goal, user details, and the context.
2. If none of the options perfectly match, and there is no search box for input, but there is a fallback option such as "Others" or "None of the above" in the HTML elements, you can consider it a match.
2. If none of the options perfectly match, and there is no search box for input, but there is a fallback option such as "Other", "Others" or "None of the above" in the HTML elements, you can consider it a match.
3. If a field is required, do not leave it blank.
4. If a field is required, do not select a placeholder value, such as "Please select", "-", or "Select...".
5. Exclude loading indicators like "loading more results" as valid options.{% if select_history %}
@@ -20,7 +20,7 @@ Reply in JSON format with the following keys:
"id": str, // The id of the element to take action on. The id has to be one from the elements list
"action_type": str, // It's a string enum: "CLICK", "INPUT_TEXT". "CLICK" is an option you'd like to click to choose. "INPUT_TEXT" is an element you'd like to input text into for searching, but it only should be used when there's no valid option to click.
"value": str, // The value to select.{% if target_value %}
"relevant": bool, // True if the value you select is relevant to the target value, otherwise False.{% endif %}
"relevant": bool, // True if the value you select is relevant to the target value, otherwise False. If the value is a fallback option according to the guidelines, it's still relevant.{% endif %}
}
Context:

View File

@@ -2336,7 +2336,8 @@ async def locate_dropdown_menu(
step: Step,
task: Task,
) -> SkyvernElement | None:
if not await current_anchor_element.is_visible():
# the anchor must exist in the DOM, but no need to be visible css style
if not await current_anchor_element.is_visible(must_visible_style=False):
return None
skyvern_frame = incremental_scraped.skyvern_frame

View File

@@ -266,9 +266,11 @@ class SkyvernElement:
async def is_selectable(self) -> bool:
return self.get_selectable() or self.get_tag_name() in SELECTABLE_ELEMENT
async def is_visible(self) -> bool:
async def is_visible(self, must_visible_style: bool = True) -> bool:
if not await self.get_locator().count():
return False
if not must_visible_style:
return True
skyvern_frame = await SkyvernFrame.create_instance(self.get_frame())
return await skyvern_frame.get_element_visible(await self.get_element_handler())