Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:MarketSquare Robotframework browser Interaction Grpc Handlers

From Leeroopedia
Revision as of 11:29, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/MarketSquare_Robotframework_browser_Interaction_Grpc_Handlers.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Browser Automation, gRPC Handlers
Last Updated 2026-02-12 05:40 GMT

Overview

Implements all user-interaction operations on page elements (click, type, select, hover, focus, checkbox, upload, dialogs, mouse, keyboard, scroll) via gRPC handlers in the Node.js Playwright wrapper.

Description

interaction.ts contains the gRPC handler functions that perform state-modifying user interactions on browser pages. Each function receives a protobuf request, resolves the target element via Playwright Locator, executes the interaction, and returns a gRPC response. The module covers:

  • Click operations: click performs standard clicks with configurable options (button, position, modifiers, force, click count). The internal internalClick helper gracefully handles "Target closed" errors that can occur when clicking triggers navigation. tap performs touch tap events.
  • Text input: typeText simulates keystroke-by-keystroke typing with configurable delay and optional pre-clear. fillText sets input values directly (like paste) with optional force. clearText empties input fields by filling with an empty string.
  • Key presses: press sends keyboard shortcuts and key combinations on a specific element, supporting a list of keys with configurable press delay and inter-key delay.
  • Select option: selectOption selects options from <select> elements by value, label, or index matcher and returns the updated selection state. deSelectOption clears all selections.
  • Hover and focus: hover moves the mouse over an element with configurable options (position, modifiers, force). focus gives keyboard focus to an element.
  • Checkbox: checkCheckbox and uncheckCheckbox toggle checkbox state, waiting for the element to be attached first and supporting force mode.
  • File upload: uploadFileBySelector sets files on an <input type="file"> element, supporting both file paths and in-memory buffers (name, mimeType, buffer). uploadFile waits for and responds to a file chooser dialog.
  • Dialog handling: handleAlert sets up a one-time event handler for the next dialog (accept/dismiss with optional prompt input). waitForAlerts processes a sequence of expected dialog actions with timeouts.
  • Mouse operations: mouseButton performs click/up/down mouse actions. mouseMove moves the cursor to specific coordinates. mouseWheel scrolls via mouse wheel with deltaX/deltaY.
  • Keyboard operations: keyboardKey performs down/up/press for individual keys. keyboardInput does virtual keyboard text entry via insertText or type action with delay.
  • Scrolling: scrollToElement scrolls an element into the visible viewport if needed.

Usage

This module is invoked by the Python-side gRPC client when Robot Framework keywords such as Click, Type Text, Fill Text, Clear Text, Press Keys, Select Options, Hover, Focus, Check Checkbox, Uncheck Checkbox, Upload File By Selector, Handle Future Dialogs, Mouse Button, Keyboard Key, Keyboard Input, and Scroll To Element are called. It is not used directly by end users.

Code Reference

Source Location

Signature

export async function selectOption(
    request: Request.SelectElementSelector, state: PlaywrightState
): Promise<Response.Select>
export async function deSelectOption(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Empty>
export async function typeText(
    request: Request.TypeText, state: PlaywrightState
): Promise<Response.Empty>
export async function fillText(
    request: Request.FillText, state: PlaywrightState
): Promise<Response.Empty>
export async function clearText(
    request: Request.ClearText, state: PlaywrightState
): Promise<Response.Empty>
export async function press(
    request: Request.PressKeys, state: PlaywrightState
): Promise<Response.Empty>
export async function click(
    request: Request.ElementSelectorWithOptions, state: PlaywrightState
): Promise<Response.Empty>
export async function tap(
    request: Request.ElementSelectorWithOptions, state: PlaywrightState
): Promise<Response.Empty>
export async function hover(
    request: Request.ElementSelectorWithOptions, state: PlaywrightState
): Promise<Response.Empty>
export async function focus(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Empty>
export async function checkCheckbox(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Empty>
export async function uncheckCheckbox(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Empty>
export async function uploadFileBySelector(
    request: Request.FileBySelector, state: PlaywrightState
): Promise<Response.Empty>
export async function uploadFile(
    request: Request.FilePath, page: Page
): Promise<Response.Empty>
export async function handleAlert(
    request: Request.AlertAction, page: Page
): Promise<Response.Empty>
export async function waitForAlerts(
    request: Request.AlertActions, page: Page
): Promise<Response.ListString>
export async function mouseButton(
    request: Request.MouseButtonOptions, page?: Page
): Promise<Response.Empty>
export async function mouseMove(
    request: Request.Json, page?: Page
): Promise<Response.Empty>
export async function mouseWheel(
    request: Request.MouseWheel, page?: Page
): Promise<Response.Empty>
export async function keyboardKey(
    request: Request.KeyboardKeypress, page: Page
): Promise<Response.Empty>
export async function keyboardInput(
    request: Request.KeyboardInputOptions, page: Page
): Promise<Response.Empty>
export async function scrollToElement(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Empty>

Import

import { Dialog, Page } from 'playwright';
import { PlaywrightState } from './playwright-state';
import { Request, Response } from './generated/playwright_pb';
import { emptyWithLog } from './response-util';
import { findLocator, invokeOnKeyboard, invokeOnMouse } from './playwright-invoke';
import { getSelections } from './getters';

I/O Contract

Inputs

Name Type Required Description
request.selector string Yes CSS, XPath, or element=uuid selector identifying the target element
request.strict boolean No Enable strict mode to fail when selector matches multiple elements
request.text string Conditional Text to type or fill into the element
request.delay number No Delay in ms between keystrokes (for typeText)
request.clear boolean No Whether to clear the field before typing
request.force boolean No Force the action even if element is not actionable
request.options string (JSON) No JSON-serialized click/hover options (button, position, modifiers, clickCount)
request.keyList string[] Conditional List of key names to press sequentially
request.matcherJson string (JSON) Conditional Matcher for select option (value, label, or index)
request.path / request.pathList string / string[] Conditional File path(s) for upload operations
request.alertAction string Conditional Dialog action: "accept" or "dismiss"
request.promptInput string No Text to enter in a prompt dialog
request.action string Conditional Mouse/keyboard action type (click, up, down, press, insertText, type)
page Page Yes Active Playwright Page instance
state PlaywrightState Yes Current Playwright state with active browser/context/page

Outputs

Name Type Description
Response.Empty gRPC Response Confirmation with log message for most interaction operations
Response.Select gRPC Response Updated select option entries after selectOption
Response.ListString gRPC Response List of alert messages collected by waitForAlerts

Usage Examples

*** Test Cases ***
Login Flow
    Type Text    id=username_field    demo    delay=50ms
    Fill Text    id=password_field    mode
    Click    id=login_button

Select and Checkbox
    Select Options By    css=select.dropdown    value    option1
    Check Checkbox    id=agree_terms
    Uncheck Checkbox    id=newsletter

File Upload
    Upload File By Selector    id=file_chooser    /path/to/file.pdf

Dialog Handling
    Handle Future Dialogs    accept
    Click    id=alerts

Mouse and Keyboard
    Mouse Button    click    x=100    y=200
    Mouse Move    x=300    y=400
    Keyboard Key    press    Enter
    Keyboard Input    type    Hello World    delay=50

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment