As I’m new to Robot framework. Im trying to run simple robot file
*** Settings ***
Library Process
*** Variables ***
${PYTHON_SCRIPT} /home/engineer/Demoproject/pythonRobotBluetoothproject/Libraries/example_script.py
*** Test Cases ***
Run Python Script
${result} = Run Process python ${PYTHON_SCRIPT}
Should Be Equal As Numbers ${result} 0
Python file
# example_script.py
def main():
print("Hello from example_script.py")
if __name__ == "__main__":
main()
Im not sure of this error .
Example Test
==============================================================================
Run Python Script | FAIL |
'<result object with rc 2>' cannot be converted to a floating point number: TypeError: float() argument must be a string or a real number, not 'ExecutionResult'
------------------------------------------------------------------------------
Example Test | FAIL |
1 test, 0 passed, 1 failed
Returns a result object containing information about the execution.
This is not a number but a complete result object, so that would explain your error, perhaps what you wanted is something like:
Should Be Equal As Numbers ${result.rc} 0
A little curious why you choose this route when you should be able to use Evaluate something like this:
Evaluate main() modules=${PYTHON_SCRIPT}
Remember Robot Framework is written in python, so can easily call any python function internally, no need to go out to a separate python process unless there’s a good reason to do so.
Thanks Dave.Getting error like this after your inputs,
Evaluating expression ‘main() modules= /home/engineer/Demoproject/pythonRobotBluetoothproject/Libraries/example_script.py’ failed: SyntaxError: invalid syntax (, line 1)
I’ve not used Evaluate exactly like that before, so not sure what the exact syntax should be, I’ve only used it with python modules that are in the path.
So normally that would look something like this:
Evaluate main() modules=example_script
But that won’t work in your case unless example_script.py is in the same folder as your robot file.