Setup Failed. No browser is open message

I am using Robot Framework 6.1.1 and Python 3.10.4 on win32 machine. Trying to automate a process using the init.robot file.
In the init.robot Suite Setup, I am using the Selenium Library. Open Browser (no webdriver) to open a Browser to the Application HomePage. Log in to the Application, click on the Reports Menu item which opens up a new window with a page for the two main Report categories.
In the Test Setup of the TestReportA1. robot file, I want to click on the click on the ReportType dropdown (on the same 2nd window), navigate to the ReportA1 link and have multiple TC’s for that ReportA1 in that file
Similar for TestReportA2.robot file-a Test Setup that will click on the Report Type dropdown, navigate to the ReportA2 link and then have multiple TC’s for that ReportA2 in that file…

The issue is that in the init.robot file, I can Open the Browser, log in to the system and navigate to the Reports Menu item and switch to the new window (I can see this via the Capture Page Screenshots). However, in the Test Setup of the TestReportA1. robot file, it cannot find the open browser. When I execute the TestReportA1.robot file, in the log.html, I see that the Suite Setup and Suite Teardown is successful but the Test Setup for that file fails with the message “Setup Failed. No Browser is open” message. What am i missing?

Folder structure:
Reports–|
|----init.robot
|
|___ Report A-----TestReportA1.robot
| Test ReportA2.robot
| TestReportA3.robot
|
|___ Report B------TestReporB1.robot
| TestReportB2.robot
| TestReportB3.robot

Welcome to the Robot Community Forum SJ !! :robot:

A few things,

You could see if using the alias argument for Open Browser and then reusing it - with the intent to reuse the existing browser - gives you the functionality you are looking for.

That should work across suite directories which using suite initialization files gets a bit tricky as to what is and isn’t shared in test suite files within the same directory, Reports in this case and then down into child folders like Report A and Report B.

Tried opening up the Browser/Switching Browser in the TestReportA1.robot file after setting the Alias as Global variable but to no luck…

It might be the issues of variable scope. I created the following example on my machine

Parent-|
|----__init__.robot
|
|- Child A/
| |-robotframework_org.robot
|- Child B/
|-google_com.robot

with __init__.robot

*** Settings ***
Library  SeleniumLibrary
Suite Setup  Create Browser

*** Keywords ***
Create Browser
    Open Browser  about:blank  Chrome  alias=${driver_alias}

robotframework_org.robot

*** Settings ***
Library  SeleniumLibrary
Library  DebugLibrary
Test Teardown  Close All Browsers

*** Variables ***
${URL}    https://robotframework.org/

*** Test Cases ***
Open the Browser To Robotframwork.org
    Create Browser    ${URL}
    Debug

*** Keywords ***
Create Browser
    [Arguments]  ${page}
    Open Browser  ${page}  Chrome  alias=${driver_alias}

google_com.robot

*** Settings ***
Library  SeleniumLibrary

*** Test Cases ***
Open Browser To Google.com
    Open Browser  https://www.google.com/  Chrome  alias=${driver_alias}

Knowing you might have experienced issues with the variable and scope I immediately started of with just passing in this alias variable. Essentially I didn’t want to have to explore the question of variable scope and went right ahead with this running this in the folder above Parent,

robot -v driver_alias:sd6 Parent

This work for me. I went ahead an checked the logs and I see on the Open Browser keyword this INFO Using existing browser from index 1. log message telling me it indeed re-used that “session”.

I suspect there are a few things maybe different between both our attempts. But this seems to confirm to me it should be possible. Note I have not gone done the path of should one structure the test suite like this debate/conversation. It is worth opening the door to that and talking about subjects like test autonomy.

Just modify mine to use a global variable set by using the ``Set Global variable` keyword instead of setting it globally via the runtime parameters. So,

__init__.robot

*** Settings ***
Library  SeleniumLibrary
Suite Setup  Create Browser

*** Variables ***
${driver_alias}    sd6

*** Keywords ***
Create Browser
    Open Browser  about:blank  Chrome  alias=${driver_alias}
    Set Global Variable  ${driver_alias}

and executed with robot Parent. I will note I do have an “issue” with reuse in the robotframework_org.robot suite above. Note on Test Teardown I run Close All browsers. In this case both with run but the google_org test won’t be reusing the browser as I close them all already.

And that might be the difference between ours. I’ll note it really isn’t super clear that one needs to essentially reuse the Open Browser keyword in each instance using the alias as a means to reuse a still open browser instance. And the reuse or start afresh isn’t initially obvious in either test case. One has to dig into the logs to see if it did indeed reuse the browser.