From 015646b1de717ebaeadf9940cf70618423e7b525 Mon Sep 17 00:00:00 2001 From: Zach Loza Date: Tue, 22 Jul 2025 10:53:14 -0400 Subject: [PATCH 1/2] Fix error in press_key act util function --- 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..9190c91e 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.locator.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 d8d3eda931a1de738a47ac6c7ebd3452b387e660 Mon Sep 17 00:00:00 2001 From: Zach Loza Date: Tue, 22 Jul 2025 13:03:32 -0400 Subject: [PATCH 2/2] Use stagehand page keyboard instead of locator --- stagehand/handlers/act_handler_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stagehand/handlers/act_handler_utils.py b/stagehand/handlers/act_handler_utils.py index 9190c91e..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.press(key) + await ctx.stagehand_page._page.keyboard.press(key) await handle_possible_page_navigation( "press", ctx.xpath,