Send strings of special keys to use e.g. Escape, Backspace, Insert, PageDown, Delete, Enter, or Shortcuts such as `Control+o`, `Control+Shift+T`
(self, request: SendKeysRequest)
| 533 | ) |
| 534 | |
| 535 | async def send_keys(self, request: SendKeysRequest) -> ActionResult: |
| 536 | """Send strings of special keys to use e.g. Escape, Backspace, Insert, PageDown, Delete, Enter, or Shortcuts such as `Control+o`, `Control+Shift+T`""" |
| 537 | # Dispatch send keys event |
| 538 | try: |
| 539 | event = self._session.event_bus.dispatch(SendKeysEvent(keys=request.keys)) |
| 540 | await event |
| 541 | await event.event_result(raise_if_any=True, raise_if_none=False) |
| 542 | memory = f'Sent keys: {request.keys}' |
| 543 | msg = f'⌨️ {memory}' |
| 544 | logger.info(msg) |
| 545 | return ActionResult( |
| 546 | success=True, |
| 547 | message=f"Successfully sent keys: {request.keys}", |
| 548 | extra={"memory": memory} |
| 549 | ) |
| 550 | except Exception as e: |
| 551 | logger.error(f'Failed to dispatch SendKeysEvent: {type(e).__name__}: {e}') |
| 552 | error_msg = f'Failed to send keys: {str(e)}' |
| 553 | return ActionResult( |
| 554 | success=False, |
| 555 | message=error_msg, |
| 556 | extra={"error": str(e)} |
| 557 | ) |
| 558 | |
| 559 | async def scroll_to_text(self, request: ScrollToTextRequest) -> ActionResult: |
| 560 | """Scroll to a text in the current page. This helps you to be efficient. Prefer this tool over scrolling step by step.""" |
nothing calls this directly
no test coverage detected