Unable to keep the same browser instance in case of an external test cases ordering


I define the order of test cases into a yaml file and then I execute it through run_cli() function as following:

for robot_file_name in robot_files:
    for case_name in cases:
         run_cli([f"-d results/{robot_file_name}/{case_name}", "--test", case_name, f"./Tests/{robot_file_name}.robot"], exit=False)

The problem I have is that when every next test case run, a new browser always opens, but I want to keep the same browser session at all cases in different robot files.

Is this possible in Robot Framework?
Is there any other function than run_cli() that solves this problem?

Hi Pavlos,

The problem here is the way you are running the tests, each time you are calling run_cli you are starting a new instance of robot framework therefore a new test suite, so there is no way to reuse the browser session.

There is a python API interface to robot framework, so maybe instead of using run_cli, you use the API to create a suite instance, then tell the suite to call the test cases in the order defined in your YAML file.

Unfortunately I don’t know the API well, I’ve dabbled in it when creating listener files, but that’s the limits of my knowledge of the API.

Hope that helps,