Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-11077): record page.evaluate as an EXECUTE_JS action in code blocks (#6600)
Aaron Pereza2e1e015391e
diff --git a/skyvern/forge/sdk/workflow/models/code_block_recorder.py b/skyvern/forge/sdk/workflow/models/code_block_recorder.pyindex 19a7e5ef6..a25db2e7f 100644--- a/skyvern/forge/sdk/workflow/models/code_block_recorder.py+++ b/skyvern/forge/sdk/workflow/models/code_block_recorder.py@@ -21,6 +21,7 @@ _PAGE_ACTION_MAP: dict[str, ActionType] = {"go_back": ActionType.GO_BACK,"go_forward": ActionType.GO_FORWARD,"reload": ActionType.RELOAD_PAGE,+ "evaluate": ActionType.EXECUTE_JS,}_LOCATOR_ACTION_MAP: dict[str, ActionType] = {"click": ActionType.CLICK,diff --git a/tests/unit/workflow/test_code_block_recorder.py b/tests/unit/workflow/test_code_block_recorder.pyindex c4e26b372..1102de988 100644--- a/tests/unit/workflow/test_code_block_recorder.py+++ b/tests/unit/workflow/test_code_block_recorder.py@@ -92,6 +92,9 @@ class FakePage:async def screenshot(self, **kwargs): # noqa: ANN003, ANN201return b"img"+ async def evaluate(self, expression, *args, **kwargs): # noqa: ANN001, ANN002, ANN003, ANN201+ return None+@pytest.mark.asyncioasync def test_records_goto_click_fill_with_types_and_order() -> None:@@ -110,6 +113,16 @@ async def test_records_goto_click_fill_with_types_and_order() -> None:assert recorded[0].description == "page.goto https://example.com"+async def test_page_evaluate_records_execute_js_action() -> None:+ page = RecordingPage(FakePage())+ await page.evaluate("() => document.title")+ recorded = page.recorded_actions()+ assert [a.action_type for a in recorded] == [ActionType.EXECUTE_JS]+ assert recorded[0].description == "page.evaluate () => document.title"+ assert recorded[0].status == ActionStatus.completed++@pytest.mark.asyncioasync def test_unmapped_calls_and_attributes_pass_through_unrecorded() -> None:fake = FakePage()