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 Network Idle Transformer

From Leeroopedia
Knowledge Sources
Domains Code Transformation, Static Analysis
Last Updated 2026-02-12 05:40 GMT

Overview

Robocop code transformer that automatically rewrites deprecated Wait Until Network Is Idle keyword calls to the replacement Wait For Load State keyword with the networkidle argument.

Description

The NetworkIdle class extends the Robocop Formatter base class to provide an automated code migration tool. It visits KeywordCall AST nodes in Robot Framework test files and detects usages of the deprecated Wait Until Network Is Idle keyword (with or without the Browser. library prefix). When a match is found, the formatter reconstructs the token list to replace the keyword name with Wait For Load State and appends networkidle as the first argument, preserving existing separator tokens and any additional arguments.

Two helper functions support the transformation: is_same_keyword compares two keyword names after normalization, and get_normalized_keyword converts camelCase or space-separated keyword names into a canonical underscore-separated lowercase form for reliable comparison.

Usage

Use this transformer when migrating Robot Framework Browser library test suites from older versions that used the Wait Until Network Is Idle keyword to current versions where the recommended approach is Wait For Load State networkidle. Run it via the Robocop formatter pipeline to batch-update all affected test files automatically.

Code Reference

Source Location

Signature

def is_same_keyword(first: str, second: str) -> bool

def get_normalized_keyword(keyword: str) -> str

class NetworkIdle(Formatter):
    def visit_KeywordCall(self, node: KeywordCall): ...
    def _keyword_formatter(self, node: KeywordCall, lib_name: bool): ...
    def _find_keyword_index(self, node: KeywordCall) -> int: ...
    def _timeout_present(self, node: KeywordCall): ...
    def _get_separator(self, node: KeywordCall) -> Token: ...

Import

from Browser.robocop_transformer.network_idle import NetworkIdle
from Browser.robocop_transformer.network_idle import is_same_keyword, get_normalized_keyword

I/O Contract

Function Input Output Description
is_same_keyword two keyword name strings bool Returns True if both keywords normalize to the same canonical form
get_normalized_keyword keyword string normalized string Converts camelCase or space-separated keyword to underscore_lowercase form
visit_KeywordCall KeywordCall AST node KeywordCall AST node Visits keyword call; returns transformed node if deprecated keyword detected, otherwise original
_keyword_formatter KeywordCall node, lib_name bool KeywordCall node Rebuilds token list replacing old keyword name with Wait For Load State and adding networkidle argument
_find_keyword_index KeywordCall node int Returns token index of the deprecated keyword name within the node
_get_separator KeywordCall node Token Returns the last separator token from the node for use in the rebuilt token list

Usage Examples

*** Test Cases ***
# Before transformation:
Example Test Before
    Wait Until Network Is Idle

# After transformation:
Example Test After
    Wait For Load State    networkidle

# With library prefix before:
Example Test Prefixed Before
    Browser.Wait Until Network Is Idle

# With library prefix after:
Example Test Prefixed After
    Browser.Wait For Load State    networkidle

Related Pages

Page Connections

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