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 Getters Grpc Handlers

From Leeroopedia
Knowledge Sources
Domains Browser Automation, gRPC Handlers
Last Updated 2026-02-12 05:40 GMT

Overview

Provides read-only getter operations for retrieving page and element properties via gRPC handlers in the Node.js Playwright wrapper layer.

Description

getters.ts implements all read-only inspection gRPC handlers that retrieve information from the browser without modifying page state. This module is the Node.js counterpart to the Python-side "Get *" keywords.

Key handler functions include:

  • Page-level getters: getTitle returns the active page title; getUrl returns the current URL; getViewportSize returns the viewport dimensions as JSON; getPageSource returns the full HTML content of the page.
  • Text content: getText retrieves text content from elements, handling <input> and <textarea> elements by returning their value property instead of innerText.
  • DOM properties: getDomProperty returns any DOM property as a JSON-serialized string; getBoolProperty returns boolean properties; getElementAttribute retrieves HTML attribute values.
  • Element states: getElementStates computes a bitwise integer representing the combined state of an element (attached/detached, visible/hidden, enabled/disabled, editable/readonly, selected/deselected, focused/defocused, checked/unchecked, stable). Uses a stateEnum mapping that mirrors the Python-side ElementState IntFlag.
  • Select elements: getSelectContent and getSelections retrieve all <option> entries from a <select> element including label, value, index, and selected status.
  • CSS styles: getStyle retrieves computed CSS styles, either a specific property or all computed styles as a dictionary, with optional pseudo-element support.
  • Bounding box: getBoundingBox returns the element's position and dimensions as {x, y, width, height}.
  • Table navigation: getTableCellIndex returns the column index of a table cell (TD/TH) within its row; getTableRowIndex returns the row index within the table.
  • Element count: getElementCount returns the number of elements matching a selector.
  • ARIA: getAriaSnapshot returns the ARIA snapshot of an element's accessible tree.

Usage

This module is invoked by the Python-side gRPC client when Robot Framework keywords such as Get Title, Get Url, Get Text, Get Property, Get Element States, Get Style, Get BoundingBox, Get Select Options, Get Viewport Size, Get Page Source, Get Table Cell Index, and Get Table Row Index are called. It is not used directly by end users.

Code Reference

Source Location

Signature

export async function getTitle(page: Page): Promise<Response.String>
export async function getUrl(page: Page): Promise<Response.String>
export async function getElementCount(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Int>
export async function getSelectContent(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Select>
export async function getDomProperty(
    request: Request.ElementProperty, state: PlaywrightState
): Promise<Response.String>
export async function getText(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.String>
export async function getBoolProperty(
    request: Request.ElementProperty, state: PlaywrightState
): Promise<Response.Bool>
export async function getElementAttribute(
    request: Request.ElementProperty, state: PlaywrightState
): Promise<Response.String>
export async function getElementStates(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Json>
export async function getStyle(
    request: Request.ElementStyle, state: PlaywrightState
): Promise<Response.Json>
export async function getViewportSize(page: Page): Promise<Response.Json>
export async function getBoundingBox(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Json>
export async function getPageSource(page: Page): Promise<Response.String>
export async function getTableCellIndex(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Int>
export async function getTableRowIndex(
    request: Request.ElementSelector, state: PlaywrightState
): Promise<Response.Int>
export async function getAriaSnapshot(
    request: Request.AriaSnapShot, state: PlaywrightState
): Promise<Response.String>

Import

import { ElementHandle, Locator, Page } from 'playwright';
import { PlaywrightState } from './playwright-state';
import { Request, Response, Types } from './generated/playwright_pb';
import { boolResponse, intResponse, jsonResponse, stringResponse } from './response-util';
import { exists, findLocator } from './playwright-invoke';

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.property string Conditional Name of the DOM property or HTML attribute to retrieve
request.styleKey string No Specific CSS property name to retrieve (empty for all styles)
request.pseudo string No CSS pseudo-element selector (e.g. "::before")
page Page Yes Active Playwright Page instance
state PlaywrightState Yes Current Playwright state with active browser/context/page

Outputs

Name Type Description
Response.String gRPC Response String results: title, URL, text content, property values, page source
Response.Int gRPC Response Integer results: element count, table cell/row index
Response.Bool gRPC Response Boolean property values (e.g. checked, disabled)
Response.Json gRPC Response JSON-serialized results: element states (bitwise int), styles, bounding boxes, viewport size
Response.Select gRPC Response Select element entries with label, value, index, and selected status

Usage Examples

*** Test Cases ***
Get Page Info
    ${title}=    Get Title
    ${url}=    Get Url
    ${source}=    Get Page Source

Get Element Text
    ${text}=    Get Text    id=heading1
    Should Be Equal    ${text}    Login Page

Get Element States
    ${states}=    Get Element States    id=username_field
    Should Contain    ${states}    visible
    Should Contain    ${states}    enabled
    Should Contain    ${states}    editable

Get Computed Style
    ${color}=    Get Style    id=heading1    color
    Log    Heading color is: ${color}

Get Select Options
    ${options}=    Get Select Options    css=select.my_drop_down
    Log    Options: ${options}

Get Bounding Box
    ${box}=    Get BoundingBox    id=login_button
    Log    Position: (${box}[x], ${box}[y]) Size: ${box}[width]x${box}[height]

Get Table Position
    ${col}=    Get Table Cell Index    css=td >> text=Username
    ${row}=    Get Table Row Index    css=td >> text=Username

Related Pages

Page Connections

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