0

I want to use the built-in variable ${OUTPUT DIR} in the variable file which is written in python.

test = 'test1'
log_file = ${OUTPUT DIR}/${test}/log.txt

I don't see any pointers about it in the official document. I could pre-process it by replacing the variables with the actual value in the file one by one to support variable substitution which would be done if variables written in the robot test file. But this ${OUTPUT DIR} has a space inside the name, thus python doesn't know how to handle it and end up a syntax error.

It's not a duplicate question as I want to use built-in variables in the variabel file which is loaded before test starts, It will cause error if I import Builtin module in the variable file, see Robotframework Listener throws "Cannot access execution context" error

pansila
  • 158
  • 1
  • 8
  • may be adding %20 instead of space will solve your problem ${OUTPUT%20DIR}, also notice that you used () instead of {} in your `log_file = $(OUTPUT DIR)/${test}/log.txt` line for ${OUTPUT DIR}, [refer this](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#automatic-variables) – Dev May 13 '19 at 10:30
  • @Dev That's a typo, thanks for your answer, I'll give it a shot. – pansila May 14 '19 at 01:52
  • @todor-minakov, It's not a duplicate question as I want to use built-in variables in the variabel file which is loaded before test starts, It will cause error if I import Builtin module in the variable file, see https://stackoverflow.com/questions/41266784/robotframework-listener-throws-cannot-access-execution-context-error – pansila May 14 '19 at 03:00
  • @bryan-oakley please help reopen it. Thanks. – pansila May 14 '19 at 03:26
  • I don't think you can access a variable like `${OUTPUT DIR}` in a python file without importing the `BuiltIn` module. Suggest you to read the [Automatic variables](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#automatic-variables), [Variable priorities and scope](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#variable-priorities-and-scopes) and [Setting variables from command line](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#setting-variables-in-command-line) from the user guide for more info – Sameem May 14 '19 at 05:32

0 Answers0