Browser Library - Switch Browser example?

Hi,
could someone post example code for creating two browser instances and switching between those using Robot Framework’s Browser (NOT using SeleniumLibrary) library?

Namely: how to obtain correct browser id for Switch Browser keyword.

Switch Browser ${ibrowser1_id}

Full code so far:

Library          Browser
Library          String
Library          Collections

** Variables **
${url1}=    https://www.google.com
${url1}=    https://www.bing.com
@{browser_ids}=    Create List

** Test Cases **
Open Browser 1
    New Browser    chromium    headless=false
    New Context    viewport={'width': 1920, 'height': 1080}
    New Page       ${url1}

Open Browser 1
    New Browser    chromium    headless=false
    New Context    viewport={'width': 1920, 'height': 1080}
    New Page       ${url2}

Page Switch tests

[Tags]   UI    dev

Switch to Browser1
Get Element   Gmail
Switch to Browser2
Get Element    © 2021 Microsoft


** Keywords **
Switch to Browser2
    Switch Page    ${browser_ids}[1]

Switch to Browser1
    Switch Page    ${browser_ids}[0]

Store Active Browser Id
    ${active_id}=    Get Page Ids   ACTIVE    ACTIVE    ACTIVE
    Log To Console    ${active_id}
    ${active_id}=    Split String    ${active_id}[0]    =
    Log To Console    ${active_id}[1]
    Append To List    ${BROWSER_IDS}    ${active_id}

Browser library has automatic teardown for Browser/Context/Page instances, so you have to create all needed instances of those in Suite Setup. Solution below:

	*** Settings ***
	Library          Browser
	#Library          OperatingSystem
	Library          Collections
	Library          String
	Suite Setup      Create Suite Ecosystem

	*** Variables ***

	@{bids}
	@{cids}
	@{pids}
	${url1}=    https://www.google.com
	${url2}=    https://www.bing.com

	*** Test Cases ***

	Setup Verification
		[Tags]   UI    dev
		${bids}=   Get Browser Ids
		Log To console    ${bids}

		${bids}=   Get Context Ids
		Log To console    ${cids}

		${pids}=   Get Page Ids
		Log To console    ${pids}

	Page Switch tests
		[Tags]   UI    dev
		Switch to Page 1
		Get Element   text=Gmail
		Switch to Page 2
		Get Element   text=© 2021 Microsoft

	** Keywords **

	Switch to Page 1
		Switch Page     ${pids}[0]

	Switch to Page 2
		Switch Page     ${pids}[1]

	Store Active Browser Id
		${active_id}=    Get Browser Ids   ACTIVE
		#${active_id}=    Split String    ${active_id}[0]    =
		Log To Console    ${active_id}[0]
		Append To List    ${bids}    ${active_id}[0]

	Store Active Context Id
		${active_id}=    Get Context Ids   ACTIVE    ACTIVE
		Log To Console    ${active_id}
		# ${active_id}=    Split String    ${active_id}[0]    =
		Log To Console    ${active_id}[0]
		Append To List    ${cids}    ${active_id}[0]

	Store Active Page Id
		[Arguments]    ${new_id}
		${active_id}=    Get Page Ids   ACTIVE    ACTIVE    ACTIVE
		# ${active_id}=    Split String    ${active_id}[0]    =
		Log To Console    ${active_id}[0]
		Append To List    ${pids}    ${new_id}

	Create Suite Ecosystem
		# Create 1B-1C-2P Ecosystem

		# 1st Browser
		New Browser    chromium    headless=false
		Store Active Browser Id

		# 1st Context of 1st Browser
		New Context    viewport={'width': 1920, 'height': 1080}
		Store Active Context Id

		# 1st Page of 1st Context of 1st Context
		New Page       ${url1}
		${current}=    Switch Page    CURRENT
		Store Active Page Id    ${current}

		# 2nd Page of 1st Context of 1st Context
		New Page       ${url2}
		${current}=    Switch Page    CURRENT
		Store Active Page Id    ${current}

Hi, in my project i’ve done like this:

First i open all my test cases with a template keyword

*** Test Cases ***
OpenAllBrowser
     [Documentation]      loop on browsers
     [Template]           OpenToDesigner
     firefox     ${INVISIBLE_BROWSER}    ${SCREEN_SIZE}    fr_FR          google.fr
     chromium    ${INVISIBLE_BROWSER}    ${SCREEN_SIZE}    ${LANGUAGE}    bing.fr

Open to designer keyword just call New Browser and New Context and New Page

this test case is in a file in an upper directory. All my real tests are in sub directories and start with a loop

*** Test Cases ***
ParseAllBrowser
   [Documentation]      loop on browsers and test each keywords
   ${browserList}       Get Browser Ids
   FOR    ${browserInstance}    IN    @{browserList}
       CreatePlaformeByMenu    ${browserInstance}
   END

in all keyword i have the command

Switch Browser                ${browserUUID}

is that help ?

Mikko Korpela from Browser development team answered this in StackOverflow: