Skip to content

Robot Framework library forces a single shared driver via ROBOT_LIBRARY_SCOPE = 'GLOBAL' #1965

Description

@rucindrea

AltTesterLibrary declares ROBOT_LIBRARY_SCOPE = 'GLOBAL' (Bindings~/robot/src/AltTesterLibrary/__init__.py:36). With GLOBAL scope Robot Framework reuses a single library instance across every WITH NAME alias, so a suite that tries to drive two AltDriver connections from one test run silently collapses both into whichever driver was initialized last.

Repro

*** Settings ***
Library    AltTesterLibrary    WITH NAME    P1
Library    AltTesterLibrary    WITH NAME    P2

*** Test Cases ***
Two Drivers
    P1.Initialize Altdriver    host=127.0.0.1    port=13000    app_name=<id-A>
    P2.Initialize Altdriver    host=127.0.0.1    port=13000    app_name=<id-B>
    # Every P1.* call now hits the P2 driver — they share state.

Discovered while writing a multiplayer smoke suite for a multi-instance Unity game. Both P1 and P2 keywords dispatched to the same instance; tests targeting "player 1" actually operated on player 2.

Why this is a bug

GLOBAL is the wrong default for any library whose state is a connection. Each WITH NAME alias should hold its own driver. The fix is one line: ROBOT_LIBRARY_SCOPE = 'SUITE' (or 'TEST'). SUITE matches the natural lifetime — Initialize Altdriver in suite setup, Stop Altdriver in suite teardown — and gives each alias its own instance.

Proposed fix

Change line 36 to ROBOT_LIBRARY_SCOPE = 'SUITE'. No public API changes; existing single-driver suites keep working because there's only ever one instance per suite anyway.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions