Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Enhance test for actor page key presses: increased sleep duration for key presses, added debug output, and improved handling of empty output.

Magnus Müller490a5b84e1e0
diff --git a/tests/ci/test_actor_page_press.py b/tests/ci/test_actor_page_press.py
index fe871f392..aa33ae086 100644
--- a/tests/ci/test_actor_page_press.py
+++ b/tests/ci/test_actor_page_press.py
@@ -253,15 +253,24 @@ async def test_press_letter_keys(browser_session, httpserver: HTTPServer):
# Press letter keys
await page.press('a')
- await asyncio.sleep(0.1)
+ await asyncio.sleep(0.2)
await page.press('B')
- await asyncio.sleep(0.1)
+ await asyncio.sleep(0.2)
# Get the output
output_text = await page.evaluate('() => document.getElementById("output").textContent')
+ print(f'DEBUG: Evaluating JavaScript: {repr(output_text)!r}')
+
import json
+ # Handle empty output gracefully
+ if not output_text or output_text.strip() == '':
+ # Wait a bit longer and try again
+ await asyncio.sleep(0.5)
+ output_text = await page.evaluate('() => document.getElementById("output").textContent')
+ print(f'DEBUG: Second attempt: {repr(output_text)!r}')
+
pressed_keys = json.loads(output_text)
# Verify letter keys