Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/fara/_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ def description(self):
* If a popup window appears that you want to close, if left_click() on the 'X' or close button doesn't work, try key(keys=['Escape']) to close it.
* On some search bars, when you type(), you may need to press_enter=False and instead separately call left_click() on the search button to submit the search query. This is especially true of search bars that have auto-suggest popups for e.g. locations
* For calendar widgets, you usually need to left_click() on arrows to move between months and left_click() on dates to select them; type() is not typically used to input dates there.
* If asked to monitor a page for changes, you can use wait() to pause for a while and avoid busy-waiting. You may also need to follow that with key() to press F5 so that the page refreshes with the latest content.
""".strip()

parameters = {
"properties": {
"action": {
"description": """
The action to perform. The available actions are:
* `key`: Performs key down presses on the arguments passed in order, then performs key releases in reverse order. Includes "Enter", "Alt", "Shift", "Tab", "Control", "Backspace", "Delete", "Escape", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageDown", "PageUp", "Shift", etc.
* `key`: Performs key down presses on the arguments passed in order, then performs key releases in reverse order. Includes "Enter", "Alt", "Shift", "Tab", "Control", "Backspace", "Delete", "Escape", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageDown", "PageUp", "Shift", "F5", etc.
* `type`: Type a string of text on the keyboard.
* `mouse_move`: Move the cursor to a specified (x, y) pixel coordinate on the screen.
* `left_click`: Click the left mouse button.
Expand Down
7 changes: 7 additions & 0 deletions src/fara/browser/playwright_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,13 @@ async def keypress(self, page: Page, keys: list[str]) -> None:
keys (List[str]): List of keys to press
"""
await self._ensure_page_ready(page)

# Special-case F5
if len(keys) == 1 and keys[0].lower() == "f5":
await page.reload()
await page.wait_for_load_state()
return

mapped_keys = [CUA_KEY_TO_PLAYWRIGHT_KEY.get(key.lower(), key) for key in keys]
try:
for key in mapped_keys:
Expand Down