add a 2-min timeout for press_sequentially (#478)
This commit is contained in:
@@ -4,3 +4,5 @@ from pathlib import Path
|
|||||||
SKYVERN_ID_ATTR: str = "unique_id"
|
SKYVERN_ID_ATTR: str = "unique_id"
|
||||||
SKYVERN_DIR = Path(__file__).parent
|
SKYVERN_DIR = Path(__file__).parent
|
||||||
REPO_ROOT_DIR = SKYVERN_DIR.parent
|
REPO_ROOT_DIR = SKYVERN_DIR.parent
|
||||||
|
|
||||||
|
INPUT_TEXT_TIMEOUT = 120000 # 2 minutes
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import structlog
|
|||||||
from deprecation import deprecated
|
from deprecation import deprecated
|
||||||
from playwright.async_api import Locator, Page, TimeoutError
|
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 (
|
from skyvern.exceptions import (
|
||||||
ImaginaryFileUrl,
|
ImaginaryFileUrl,
|
||||||
InvalidElementForTextInput,
|
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
|
# 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
|
# 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=INPUT_TEXT_TIMEOUT)
|
||||||
await locator.press_sequentially(text, timeout=total_timeout)
|
|
||||||
return [ActionSuccess()]
|
return [ActionSuccess()]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from enum import StrEnum
|
|||||||
import structlog
|
import structlog
|
||||||
from playwright.async_api import FrameLocator, Locator, Page
|
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 (
|
from skyvern.exceptions import (
|
||||||
ElementIsNotLabel,
|
ElementIsNotLabel,
|
||||||
MissingElement,
|
MissingElement,
|
||||||
@@ -17,7 +17,6 @@ from skyvern.forge.sdk.settings_manager import SettingsManager
|
|||||||
from skyvern.webeye.scraper.scraper import ScrapedPage
|
from skyvern.webeye.scraper.scraper import ScrapedPage
|
||||||
|
|
||||||
LOG = structlog.get_logger()
|
LOG = structlog.get_logger()
|
||||||
TEXT_INPUT_DELAY = 10
|
|
||||||
|
|
||||||
|
|
||||||
def resolve_locator(scrape_page: ScrapedPage, page: Page, frame: str, xpath: str) -> Locator:
|
def resolve_locator(scrape_page: ScrapedPage, page: Page, frame: str, xpath: str) -> Locator:
|
||||||
@@ -97,8 +96,7 @@ class SkyvernElement:
|
|||||||
async def input_sequentially(
|
async def input_sequentially(
|
||||||
self, text: str, default_timeout: float = SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS
|
self, text: str, default_timeout: float = SettingsManager.get_settings().BROWSER_ACTION_TIMEOUT_MS
|
||||||
) -> None:
|
) -> None:
|
||||||
total_timeout = max(len(text) * TEXT_INPUT_DELAY * 3, default_timeout)
|
await self.locator.press_sequentially(text, timeout=INPUT_TEXT_TIMEOUT)
|
||||||
await self.locator.press_sequentially(text, timeout=total_timeout)
|
|
||||||
|
|
||||||
|
|
||||||
class DomUtil:
|
class DomUtil:
|
||||||
|
|||||||
Reference in New Issue
Block a user