Skip to content

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

Closed

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.

Activity

  1. self-assigned this
    on May 19, 2026
  2. MihaiCuc98 commented on May 19, 2026

    @MihaiCuc98
    Contributor

    Tested on:

    • Windows 11: AltTester® Desktop v.2.3.2-2b2f3d5 - Pro
    • Sample game standalone b86d9e3094ab988ee24aff151dbcf95a6f51e574
    • Robot bindings

    Checks:

    • ✅ Run all the tests from bindings -> all the tests pass report.html

    • ✅ Run a sample test that uses 2 instances and the drivers connects to the expected game report.html:

    *** Settings ***
    Library    AltTesterLibrary    WITH NAME    P1
    Library    AltTesterLibrary    WITH NAME    P2
    *** Test Cases ***
    Two Players Connect Independently
        P1.Initialize Altdriver    host=127.0.0.1    port=13000    app_name=player-one
        P2.Initialize Altdriver    host=127.0.0.1    port=13000    app_name=player-two
        ${scene_p1}=    P1.Get Current Scene
        Should Be Equal    ${scene_p1}    Scene 1 AltDriverTestScene
        ${scene_p2}=    P2.Get Current Scene
        Should Be Equal    ${scene_p2}    Scene 5 Keyboard Input
        
        [Teardown]    Run Keywords    P1.Stop Altdriver    AND    P2.Stop Altdriver
    
    • ✅ Check also the docs for typos and wrong info.
    Image

    Conclusion:

    The issue is now addressed. Moving the ticket to Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions