Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
ifx chain click bug (#576)
LawyZheng0ddda3f481ba
diff --git a/skyvern/exceptions.py b/skyvern/exceptions.pyindex 4ab7ad524..3477a4580 100644--- a/skyvern/exceptions.py+++ b/skyvern/exceptions.py@@ -421,3 +421,10 @@ class FailedToGetCurrentValueOfDropdown(SkyvernException):class HttpException(SkyvernException):def __init__(self, status_code: int, url: str, msg: str | None = None) -> None:super().__init__(f"HTTP Exception, status_code={status_code}, url={url}" + (f", msg={msg}" if msg else ""))+++class WrongElementToUploadFile(SkyvernException):+ def __init__(self, element_id: str):+ super().__init__(+ f"No file chooser dialog opens, so file can't be uploaded through element {element_id}. Please try to upload again with another element."+ )diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.pyindex ce114edbf..fc81968a3 100644--- a/skyvern/webeye/actions/handler.py+++ b/skyvern/webeye/actions/handler.py@@ -6,7 +6,7 @@ from typing import Any, Awaitable, Callable, Listimport structlogfrom deprecation import deprecated-from playwright.async_api import Locator, Page, TimeoutError+from playwright.async_api import FileChooser, Locator, Page, TimeoutErrorfrom skyvern.constants import REPO_ROOT_DIRfrom skyvern.exceptions import (@@ -24,6 +24,7 @@ from skyvern.exceptions import (MultipleElementsFound,NoSelectableElementFound,OptionIndexOutOfBound,+ WrongElementToUploadFile,)from skyvern.forge import appfrom skyvern.forge.prompts import prompt_engine@@ -712,7 +713,13 @@ async def chain_click()file = []- fc_func = lambda fc: fc.set_files(files=file) # noqa: E731+ is_filechooser_trigger = False++ async def fc_func(fc: FileChooser) -> None:+ await fc.set_files(files=file)+ nonlocal is_filechooser_trigger+ is_filechooser_trigger = True+page.on("filechooser", fc_func)LOG.info("Registered file chooser listener", action=action, path=file)@@ -795,6 +802,13 @@ async def chain_click(await asyncio.sleep(10)page.remove_listener("filechooser", fc_func)+ if action.file_url and not is_filechooser_trigger:+ LOG.warning(+ "Action has file_url, but filechoose even hasn't been triggered. Upload file attempt seems to fail",+ action=action,+ )+ return [ActionFailure(WrongElementToUploadFile(action.element_id))]+async def normal_select(action: actions.SelectOptionAction,