[HELP]: how to use python run a robot file and pass variables , get runtime variables?

a robot script

*** Settings ***
Library     String
Library     Browser
Library     OperatingSystem
Library     Process


*** Variables ***
${python_get_var}     123
${GLOBAL_VARIABLE}    0


*** Test Cases ***
translator
   
    New Browser    chromium    headless=false    args=["--start-maximized",]
    New Page    https://bing.com

how to use python run this script and get variable python_get_var to python scope

forget thing:

*** Settings ***
Library     String
Library     Browser
Library     OperatingSystem
Library     Process


*** Variables ***
${python_get_var}     123
${GLOBAL_VARIABLE}    0
# ${a_var_set_by_python}    222


*** Test Cases ***
translator
   
    New Browser    chromium    headless=false    args=["--start-maximized",]
    New Page    https://bing.com

use python run robot script and dynamic pass variables a_var_set_by_python

And I alse want to get variables python_get_var by python in runtime that origin define in robot

Robot Framework is a test runner. Trying to run a test runner by another (test) runner is generally overcomplicating things. What problem are you trying to solve here? Why do you need access to that variable on the Python side?

Note that this is possible using robot.BuiltIn(), but only when robot is actually executing a suite.

1 Like