From d61968b83b018ba557824ace76136847364e3ee4 Mon Sep 17 00:00:00 2001 From: Zach Loza Date: Tue, 22 Jul 2025 16:32:16 -0400 Subject: [PATCH 1/2] Fix error in press_key act util function (#155) * Fix error in press_key act util function * Use stagehand page keyboard instead of locator --- stagehand/handlers/act_handler_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stagehand/handlers/act_handler_utils.py b/stagehand/handlers/act_handler_utils.py index 0455820b..947cf433 100644 --- a/stagehand/handlers/act_handler_utils.py +++ b/stagehand/handlers/act_handler_utils.py @@ -307,7 +307,7 @@ async def fill_or_type(ctx: MethodHandlerContext) -> None: async def press_key(ctx: MethodHandlerContext) -> None: try: key = str(ctx.args[0]) if ctx.args and ctx.args[0] is not None else "" - await ctx.locator._page.keyboard.press(key) + await ctx.stagehand_page._page.keyboard.press(key) await handle_possible_page_navigation( "press", ctx.xpath, @@ -398,7 +398,7 @@ async def fallback_locator_method(ctx: MethodHandlerContext) -> None: ctx.logger.debug( message="page URL before action", category="action", - auxiliary={"url": {"value": ctx.locator._page.url, "type": "string"}}, + auxiliary={"url": {"value": ctx.stagehand_page._page.url, "type": "string"}}, ) try: method_to_call = getattr(ctx.locator, ctx.method) From d7469f51c7e10945782a005057bec82293f2beff Mon Sep 17 00:00:00 2001 From: miguel Date: Tue, 22 Jul 2025 15:34:02 -0700 Subject: [PATCH 2/2] changeset --- .changeset/sceptical-mutant-shrew.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sceptical-mutant-shrew.md diff --git a/.changeset/sceptical-mutant-shrew.md b/.changeset/sceptical-mutant-shrew.md new file mode 100644 index 00000000..cd16941a --- /dev/null +++ b/.changeset/sceptical-mutant-shrew.md @@ -0,0 +1,5 @@ +--- +"stagehand": patch +--- + +Fix error in press_key act util function