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 Clock Keywords

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

Overview

Provides keywords for controlling the browser's internal clock, enabling deterministic testing of time-dependent functionality via Playwright's Clock API.

Description

The Clock class extends LibraryComponent and provides four Robot Framework keywords for manipulating the browser's internal clock. Set Time (set_time) sets the browser clock to a specific datetime with configurable clock types: install (fake timers for manual time control), fixed (returns fixed time while keeping timers running), and system (sets system time without triggering timers). Advance Clock (advance_clock) moves the clock forward by a timedelta with either fast_forward (jumps forward, fires due timers at most once) or run_forward (fires all time-related callbacks). Resume Clock (resume_clock) resumes normal time flow after manipulation. Pause At (pause_at) jumps forward to a specified time and pauses, simulating a laptop lid close/reopen scenario. All keywords communicate with the Playwright backend via gRPC.

Usage

Use these keywords when testing time-dependent features such as session timeouts, scheduled UI updates, animations, or countdown timers. They allow deterministic control over time progression without waiting for real time to elapse.

Code Reference

Source Location

Signature

class Clock(LibraryComponent):

    def set_time(self, time: datetime, clock_type: ClockType = ClockType.install):

    def resume_clock(self):

    def pause_at(self, time: datetime):

    def advance_clock(
        self,
        time: timedelta,
        advance_type: CLockAdvanceType = CLockAdvanceType.fast_forward,
    ):

Import

from Browser.keywords.clock import Clock

I/O Contract

Inputs

Name Type Required Description
time datetime Yes (for set_time, pause_at) The target datetime value. Supports Robot Framework date and time format.
clock_type ClockType No The clock type for set_time. Options are install (fake timers), fixed (fixed time with running timers), and system (system time without triggering timers). Default is install.
time timedelta Yes (for advance_clock) The duration to advance the clock by.
advance_type CLockAdvanceType No The type of clock advance. Options are fast_forward (jump forward, fire due timers once) and run_forward (fire all time-related callbacks). Default is fast_forward.

Outputs

Name Type Description
None None All clock keywords return None. They modify browser state via gRPC side effects.

Usage Examples

Robot Framework

*** Test Cases ***
Test With Controlled Clock
    Set Time    2024-10-31 17:34:00
    Go To    ${URL}
    # Verify time-dependent elements at the set time
    Get Text    id=clock-display    ==    17:34:00
    Advance Clock    01:00:00
    Get Text    id=clock-display    ==    18:34:00
    Resume Clock

Test Pause And Resume
    Set Time    2024-10-31 17:34:00
    Do Something
    Pause At    2024-10-31 18:34:00
    Check Something
    Resume Clock
    Do Something Else

Related Pages

Page Connections

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