support shadow dom (#555)

This commit is contained in:
LawyZheng
2024-07-05 02:54:49 +08:00
committed by GitHub
parent be97d0bdb1
commit 690c1a1a96
3 changed files with 85 additions and 28 deletions

View File

@@ -6,7 +6,7 @@ from enum import StrEnum
from typing import Any, Awaitable, Callable
import structlog
from playwright.async_api import Frame, Page
from playwright.async_api import ElementHandle, Frame, Page
from pydantic import BaseModel
from skyvern.constants import PAGE_CONTENT_TIMEOUT, SKYVERN_DIR, SKYVERN_ID_ATTR
@@ -318,10 +318,10 @@ async def get_page_content(page: Page, timeout: float = PAGE_CONTENT_TIMEOUT) ->
return await page.content()
async def get_select2_options(page: Page) -> list[dict[str, Any]]:
async def get_select2_options(page: Page, element: ElementHandle) -> list[dict[str, Any]]:
await page.evaluate(JS_FUNCTION_DEFS)
js_script = "async () => await getSelect2Options()"
return await page.evaluate(js_script)
js_script = "async (element) => await getSelect2Options(element)"
return await page.evaluate(js_script, element)
async def get_interactable_element_tree_in_frame(