Skip if selected (#604)

This commit is contained in:
LawyZheng
2024-07-16 01:41:56 +08:00
committed by GitHub
parent 33ab70dd8b
commit 9b51df4ffd
2 changed files with 21 additions and 12 deletions

View File

@@ -424,7 +424,6 @@ async def handle_select_option_action(
) -> list[ActionResult]:
dom = DomUtil(scraped_page, page)
skyvern_element = await dom.get_skyvern_element_by_id(action.element_id)
locator = skyvern_element.locator
tag_name = skyvern_element.get_tag_name()
element_dict = scraped_page.id_to_element_dict[action.element_id]
@@ -583,13 +582,6 @@ async def handle_select_option_action(
click_action = ClickAction(element_id=action.element_id)
return await chain_click(task, scraped_page, page, click_action, skyvern_element)
try:
current_text = await locator.input_value()
if current_text == action.option.label or current_text == action.option.value:
return [ActionSuccess()]
except Exception:
LOG.info("failed to confirm if the select option has been done, force to take the action again.")
return await normal_select(action=action, skyvern_element=skyvern_element)
@@ -828,9 +820,16 @@ async def normal_select(
action: actions.SelectOptionAction,
skyvern_element: SkyvernElement,
) -> List[ActionResult]:
try:
current_text = await skyvern_element.get_attr("selected")
if current_text == action.option.label or current_text == action.option.value:
return [ActionSuccess()]
except Exception:
LOG.info("failed to confirm if the select option has been done, force to take the action again.")
action_result: List[ActionResult] = []
is_success = False
locator = skyvern_element.locator
locator = skyvern_element.get_locator()
try:
await locator.click(