ifx chain click bug (#576)
This commit is contained in:
@@ -421,3 +421,10 @@ class FailedToGetCurrentValueOfDropdown(SkyvernException):
|
|||||||
class HttpException(SkyvernException):
|
class HttpException(SkyvernException):
|
||||||
def __init__(self, status_code: int, url: str, msg: str | None = None) -> None:
|
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 ""))
|
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."
|
||||||
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from typing import Any, Awaitable, Callable, List
|
|||||||
|
|
||||||
import structlog
|
import structlog
|
||||||
from deprecation import deprecated
|
from deprecation import deprecated
|
||||||
from playwright.async_api import Locator, Page, TimeoutError
|
from playwright.async_api import FileChooser, Locator, Page, TimeoutError
|
||||||
|
|
||||||
from skyvern.constants import REPO_ROOT_DIR
|
from skyvern.constants import REPO_ROOT_DIR
|
||||||
from skyvern.exceptions import (
|
from skyvern.exceptions import (
|
||||||
@@ -24,6 +24,7 @@ from skyvern.exceptions import (
|
|||||||
MultipleElementsFound,
|
MultipleElementsFound,
|
||||||
NoSelectableElementFound,
|
NoSelectableElementFound,
|
||||||
OptionIndexOutOfBound,
|
OptionIndexOutOfBound,
|
||||||
|
WrongElementToUploadFile,
|
||||||
)
|
)
|
||||||
from skyvern.forge import app
|
from skyvern.forge import app
|
||||||
from skyvern.forge.prompts import prompt_engine
|
from skyvern.forge.prompts import prompt_engine
|
||||||
@@ -712,7 +713,13 @@ async def chain_click(
|
|||||||
)
|
)
|
||||||
file = []
|
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)
|
page.on("filechooser", fc_func)
|
||||||
LOG.info("Registered file chooser listener", action=action, path=file)
|
LOG.info("Registered file chooser listener", action=action, path=file)
|
||||||
|
|
||||||
@@ -795,6 +802,13 @@ async def chain_click(
|
|||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
page.remove_listener("filechooser", fc_func)
|
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(
|
async def normal_select(
|
||||||
action: actions.SelectOptionAction,
|
action: actions.SelectOptionAction,
|
||||||
|
|||||||
Reference in New Issue
Block a user