Reputation: 1
I'm beginner in robot framework. I want to pass values from python file to variable of robot framework, but still can't work successfully.
globe.py
is my python file and it's very simple.
a = 'this is testing'
below is test case configuration as robot required
*** Setting ***
|Variables|globe.py
*** Variables ***
|${myTest}|${a}
but robot throw error :
"Error in file: Setting variable '${myTest}' failed: Variable '${a}' not found."
could you give some suggestion on that?
here is screen about my execution steps and result
Upvotes: 0
Views: 6181
Reputation: 2615
The other workaround is using --variablefile option of robotframework.
Test_varaibles.robot
*** Settings ***
*** Variables ***
*** Test Cases ***
print message to console
print msg
*** Keywords ***
print msg
log to console ${msg}
Declare a variable msg in a python file
variable.py
msg='Hello!! This is First msg!'
To pass a variable file, we need to pass –variablefile or -V as a command line argument to pybot
run below command
pybot -V variable.py Test_variables.robot
For more descriptive details, you can also refer below
Upvotes: 0
Reputation: 193
You can also try to import the variables .py file prior to use..
Import Library <yourPythonFile.py>
#use variables from python variables file after successful import..
Upvotes: 1
Reputation: 6981
It seems to me that your example does work. I use the tab delimited approach, but that shouldn't be the cause.
*** Setting ***
Variables globe.py
*** Variables ***
${myTest} ${a}
*** Test Cases ***
A Test Case
Log To Console ${myTest}
This resulted into this response from Robot Framework which appears to be what you're looking for.
Suite Executor: Robot Framework 3.0 (Python 2.7.9 on win32)
==============================================================================
MyLibrary
==============================================================================
MyLibrary.Test
==============================================================================
A Test Case this is testing
| PASS |
------------------------------------------------------------------------------
MyLibrary.Test | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
MyLibrary | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
Upvotes: 1