[英]how to run a robot framework script with python 3.7 from the terminal
[英]How to run python script in robot framework properly
我是机器人框架的新手,我有一个 python 脚本,我想在机器人框架中运行,但它运行不正常,它失败了,output 没有脚本(错误:''不包含'hello')
机器人框架文件:
*** Settings ***
Library OperatingSystem
Library Process
*** Test Cases ***
Simple pyhton example
${result} = Run Process python3 hello.py -c arg1 -b arg2
Log ${result.stdout}
Should Contain ${result.stdout} hello
py文件:
import sys
print("This is the name of the script:", sys.argv[0])
print("Number of arguments:", len(sys.argv))
print("The arguments are:", str(sys.argv))
print("hello world")
首先,您的 hello.py 文件需要包含一个 function (或带有方法的 class )。 不确定您想对特定的 arguments 做什么,但内容可能如下所示:
def hello_world(name, friend):
return "hello " + name + " and " + friend
现在您可以将它作为库导入到您的机器人文件中并调用 function:
*** Settings ***
Library hello.py
*** Test Cases ***
Simple Pyhton Example
${result} Hello World bitrex superman
Log ${result}
Should Contain ${result} hello
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.