From af81fb720625c1ed1ddf68ff4f23f8f016a76abd Mon Sep 17 00:00:00 2001 From: Kerem Yilmaz Date: Sun, 16 Jun 2024 16:33:25 -0700 Subject: [PATCH] add a 2-min timeout for press_sequentially (#478) --- skyvern/constants.py | 2 ++ skyvern/webeye/actions/handler.py | 5 ++--- skyvern/webeye/utils/dom.py | 6 ++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/skyvern/constants.py b/skyvern/constants.py index a08a5320..3cd026a5 100644 --- a/skyvern/constants.py +++ b/skyvern/constants.py @@ -4,3 +4,5 @@ from pathlib import Path SKYVERN_ID_ATTR: str = "unique_id" SKYVERN_DIR = Path(__file__).parent REPO_ROOT_DIR = SKYVERN_DIR.parent + +INPUT_TEXT_TIMEOUT = 120000 # 2 minutes diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.py index 2dc66561..1881e0e3 100644 --- a/skyvern/webeye/actions/handler.py +++ b/skyvern/webeye/actions/handler.py @@ -8,7 +8,7 @@ import structlog from deprecation import deprecated from playwright.async_api import Locator, Page, TimeoutError -from skyvern.constants import REPO_ROOT_DIR +from skyvern.constants import INPUT_TEXT_TIMEOUT, REPO_ROOT_DIR from skyvern.exceptions import ( ImaginaryFileUrl, InvalidElementForTextInput, @@ -268,8 +268,7 @@ async def handle_input_text_action( # If the input is a text input, we type the text character by character # 3 times the time it takes to type the text so it has time to finish typing - total_timeout = max(len(text) * TEXT_INPUT_DELAY * 3, SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS) - await locator.press_sequentially(text, timeout=total_timeout) + await locator.press_sequentially(text, timeout=INPUT_TEXT_TIMEOUT) return [ActionSuccess()] diff --git a/skyvern/webeye/utils/dom.py b/skyvern/webeye/utils/dom.py index 084f4ef1..bfae0e4e 100644 --- a/skyvern/webeye/utils/dom.py +++ b/skyvern/webeye/utils/dom.py @@ -4,7 +4,7 @@ from enum import StrEnum import structlog from playwright.async_api import FrameLocator, Locator, Page -from skyvern.constants import SKYVERN_ID_ATTR +from skyvern.constants import INPUT_TEXT_TIMEOUT, SKYVERN_ID_ATTR from skyvern.exceptions import ( ElementIsNotLabel, MissingElement, @@ -17,7 +17,6 @@ from skyvern.forge.sdk.settings_manager import SettingsManager from skyvern.webeye.scraper.scraper import ScrapedPage LOG = structlog.get_logger() -TEXT_INPUT_DELAY = 10 def resolve_locator(scrape_page: ScrapedPage, page: Page, frame: str, xpath: str) -> Locator: @@ -97,8 +96,7 @@ class SkyvernElement: async def input_sequentially( self, text: str, default_timeout: float = SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS ) -> None: - total_timeout = max(len(text) * TEXT_INPUT_DELAY * 3, default_timeout) - await self.locator.press_sequentially(text, timeout=total_timeout) + await self.locator.press_sequentially(text, timeout=INPUT_TEXT_TIMEOUT) class DomUtil: