From 07fd58be23366bd770fcf996084ab181fb39dc82 Mon Sep 17 00:00:00 2001 From: Kerem Yilmaz Date: Mon, 17 Jun 2024 08:37:31 -0700 Subject: [PATCH] Select option handler bugfix (#482) --- skyvern/webeye/actions/handler.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.py index 1881e0e3..c2ddd2b1 100644 --- a/skyvern/webeye/actions/handler.py +++ b/skyvern/webeye/actions/handler.py @@ -516,8 +516,11 @@ async def handle_select_option_action( check_action = CheckboxAction(element_id=action.element_id, is_checked=True) return await handle_checkbox_action(check_action, page, scraped_page, task, step) - current_text = await locator.input_value() - if current_text == action.option.label: + current_value = await locator.input_value() + # find the text of the option with the current value + option_locator = locator.locator(f'option[value="{current_value}"]') + option_text = await option_locator.text_content() + if option_text == action.option.label: return [ActionSuccess()] try: @@ -529,9 +532,8 @@ async def handle_select_option_action( label=action.option.label, timeout=SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS, ) - await locator.click( - timeout=SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS, - ) + # In case we need to unfocus the select element, press Tab + await page.keyboard.press("Tab") return [ActionSuccess()] except Exception as e: if action.option.index is not None: