Skip to content

Automate browser based workflows with AI

improve dropdown detect (#1927)

Shuchang Zhenga572126d61dc
diff --git a/skyvern/forge/prompts/skyvern/custom-select.j2 b/skyvern/forge/prompts/skyvern/custom-select.j2
index 6277b68d2..cd721e2af 100644
--- a/skyvern/forge/prompts/skyvern/custom-select.j2
+++ b/skyvern/forge/prompts/skyvern/custom-select.j2
@@ -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:
diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.py
index 33e8dea4f..7ea129764 100644
--- a/skyvern/webeye/actions/handler.py
+++ b/skyvern/webeye/actions/handler.py
@@ -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
diff --git a/skyvern/webeye/utils/dom.py b/skyvern/webeye/utils/dom.py
index 68c917371..b487b41cc 100644
--- a/skyvern/webeye/utils/dom.py
+++ b/skyvern/webeye/utils/dom.py
@@ -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())