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.

Workflow:MarketSquare Robotframework browser Browser Test Authoring

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Test_Automation, Web_Testing
Last Updated 2026-02-12 04:00 GMT

Overview

End-to-end process for writing and executing browser-based UI tests using the robotframework-browser library with Robot Framework.

Description

This workflow covers the core use case of the Browser library: authoring Robot Framework test cases that automate browser interactions. It spans from importing the library, managing browser and context lifecycle, navigating to pages, interacting with elements (clicking, typing, selecting), asserting page state, and handling advanced patterns like waiting, promises, and storage state reuse. The library communicates with Playwright via a gRPC bridge, providing access to Chromium, Firefox, and WebKit browsers.

Usage

Execute this workflow when you need to create automated browser tests for web applications using Robot Framework. This is the primary use case for anyone adopting the Browser library for functional UI testing, regression testing, or end-to-end testing of web applications.

Execution Steps

Step 1: Import Library and Configure Settings

Import the Browser library in the Robot Framework Settings section. Optionally configure library-level settings such as timeout, retry assertions duration, strict mode, and selector prefix. These settings control the default behavior for all keywords and can be overridden at suite or test level.

Key considerations:

  • Timeout controls how long keywords wait for elements (default varies)
  • Strict mode enforces single-element matching for selectors
  • Selector prefix can be set to scope all selectors under a common parent
  • Settings can be scoped to Global, Suite, or Test level via the SettingsStack

Step 2: Manage Browser and Context Lifecycle

Open a browser instance using New Browser, create a browser context with New Context (configuring viewport, locale, permissions, proxy, etc.), and open pages with New Page. The library manages a stack of browsers, contexts, and pages. Contexts provide isolated sessions (separate cookies, storage, authentication).

Key considerations:

  • Multiple browsers can run simultaneously (Chromium, Firefox, WebKit)
  • Each context is an isolated browser session
  • Video recording and tracing can be enabled at context creation time
  • Device emulation is supported via Get Device descriptors
  • Use Save Storage State and New Context with storage state to reuse authentication

Step 3: Navigate and Interact with Elements

Use Go To to navigate to URLs, then interact with page elements using keywords like Click, Fill Text, Type Text, Select Options By, Check Checkbox, Press Keys, Hover, Focus, Scroll To Element, and Drag And Drop. The library supports chained selectors combining CSS, text, and XPath strategies using the >> syntax.

Key considerations:

  • Selectors support chaining: div.dialog >> "Ok" combines CSS and text selectors
  • Fill Text clears and fills a field; Type Text types character by character
  • Fill Secret and Type Secret handle sensitive data without logging
  • Auto-waiting ensures elements are actionable before interaction
  • Locator handlers can automatically dismiss overlays during interactions

Step 4: Assert Page State

Verify expected outcomes using assertion keywords like Get Text, Get Title, Get Url, Get Property, Get Attribute, Get Style, Get Element Count, and Get Checkbox State. These keywords support inline assertions with operators (==, !=, contains, matches, etc.) and automatic retry polling via the assertion engine.

Key considerations:

  • Assertion keywords automatically retry until the assertion passes or timeout expires
  • Supported assertion operators: ==, !=, <, >, <=, >=, contains, not contains, starts, ends, matches, validate
  • Custom formatters can transform values before comparison (e.g., strip, normalize)
  • Wait For Elements State provides explicit waiting for element visibility, attachment, etc.

Step 5: Handle Asynchronous Operations

Use Promise To to start asynchronous operations (like waiting for network responses or navigation) and Wait For to resolve them. This enables patterns like clicking a button that triggers a delayed request and capturing the response.

Key considerations:

  • Promise To wraps any Browser keyword for async execution
  • Wait For blocks until the promise resolves
  • Wait For Response and Wait For Request capture network traffic
  • Wait For Navigation handles page transitions triggered by user actions

Step 6: Cleanup and Reporting

Close browsers, contexts, and pages after tests complete. The library automatically closes resources when the Robot Framework suite ends via Listener hooks. Configure Register Keyword To Run On Failure for automatic screenshots or other actions on test failure. Trace files can be viewed with rfbrowser show-trace.

Key considerations:

  • Resources are automatically cleaned up at suite teardown via Listener v2 hooks
  • Run On Failure captures screenshots or other diagnostics automatically
  • Tracing groups organize Playwright traces by test case for easy debugging
  • Video recordings are saved when the context is closed

Execution Diagram

GitHub URL

Workflow Repository