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 Run On Failure Keywords

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

Overview

Provides the Robot Framework keyword for configuring which keyword automatically executes when a Browser library keyword fails.

Description

The RunOnFailureKeywords class extends LibraryComponent and exposes a single keyword:

  • Register Keyword To Run On Failure -- Sets a keyword (with optional arguments) that will be automatically invoked whenever any Browser library keyword fails. The default failure keyword is Take Screenshot. The keyword supports scoped configuration via the scope argument (Global, Suite, or Test/Task). Passing the string "NONE" or Python None disables the feature entirely.

The keyword returns a DelayedKeyword object representing the previously registered failure keyword, allowing callers to restore the original configuration later. When Take Screenshot is registered without arguments, the library uses ${TEST NAME}_FAILURE_SCREENSHOT_{index} as the filename pattern instead of the default filename.

This implementation is derived from the SeleniumLibrary run-on-failure pattern and adapted for the Browser library.

Usage

Use this keyword at the start of a test suite or test case to configure automatic failure handling. Register Take Screenshot for visual debugging, or register a custom keyword for specialized failure reporting. Disable the feature with "NONE" when failure screenshots would slow down execution or are not needed.

Code Reference

Source Location

Signature

class RunOnFailureKeywords(LibraryComponent):
    @keyword(tags=("Config",))
    def register_keyword_to_run_on_failure(
        self, keyword: str | None, *args: str, scope: Scope = Scope.Global
    ) -> DelayedKeyword: ...

Import

from Browser.keywords.runonfailure import RunOnFailureKeywords

I/O Contract

Register Keyword To Run On Failure

Direction Name Type Description
Input keyword str or None Name of the keyword to run on failure; "NONE" or None disables the feature
Input *args str Optional arguments to pass to the failure keyword
Input scope Scope Lifetime scope: Global, Suite, or Test/Task (default: Global)
Output return DelayedKeyword Object containing the previously registered keyword name and arguments

Usage Examples

Robot Framework

*** Settings ***
Library    Browser

*** Test Cases ***
Configure Default Screenshot On Failure
    Register Keyword To Run On Failure    Take Screenshot

Configure Screenshot With Custom Filename
    Register Keyword To Run On Failure    Take Screenshot    robotframework-browser-screenshot-{index}

Configure Screenshot With Full Page Option
    Register Keyword To Run On Failure    Take Screenshot    failure-{index}    fullPage=True

Disable Run On Failure
    ${previous_kw}=    Register Keyword To Run On Failure    NONE
    # Perform operations without failure screenshots
    Log    No screenshots on failure

Restore Previous Failure Keyword
    ${previous_kw}=    Register Keyword To Run On Failure    NONE
    # ... do something ...
    Register Keyword To Run On Failure    ${previous_kw}

Related Pages

Page Connections

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