在机器人框架中使用 python 脚本
Use python script in robot framework
请帮忙理解
我有脚本 (SplitModule.py) :
from robot.api.deco import keyword
@keyword('Split Function')
def splitfunction(string):
print "atata"
new_list = string.split(",")
return new_list
和机器人框架脚本test.txt:
*** Settings ***
Library DiffLibrary
Library String
Library OperatingSystem
Library Collections
Library SplitModule.py
*** Test Cases ***
Example of calling a python keyword that calls a robot keyword
Split Function ${services}
但是我的功能有问题,有出来:
============================================================================== Robot
============================================================================== Robot.Check Services
============================================================================== Example of calling a python keyword that calls a robot keyword
| FAIL | No keyword with name 'Split Function ${services}' found.
------------------------------------------------------------------------------ Robot.Check Services
| FAIL | 1 critical test, 0 passed, 1 failed 1 test total, 0 passed, 1
failed
============================================================================== Robot
| FAIL | 1 critical test, 0 passed, 1 failed 1 test total, 0 passed, 1
failed
============================================================================== Output: /opt/robot/logs/output.xml Log: /opt/robot/logs/log.html
Report: /opt/robot/logs/report.html
有什么问题吗?谢谢
阅读错误消息告诉您的内容:
No keyword with name 'Split Function ${services}' found.
它认为测试试图调用关键字Split Function ${services}
。您没有使用该名称的关键字。你做的是一个名为Split Function
的关键字,它接受一个参数。因此,您需要使用正确的语法将参数传递给关键字。
换句话说,关键字和参数之间需要两个或更多空格:
Split Function ${services} # need at least two spaces before $
请帮忙理解
我有脚本 (SplitModule.py) :
from robot.api.deco import keyword
@keyword('Split Function')
def splitfunction(string):
print "atata"
new_list = string.split(",")
return new_list
和机器人框架脚本test.txt:
*** Settings ***
Library DiffLibrary
Library String
Library OperatingSystem
Library Collections
Library SplitModule.py
*** Test Cases ***
Example of calling a python keyword that calls a robot keyword
Split Function ${services}
但是我的功能有问题,有出来:
============================================================================== Robot ============================================================================== Robot.Check Services ============================================================================== Example of calling a python keyword that calls a robot keyword
| FAIL | No keyword with name 'Split Function ${services}' found. ------------------------------------------------------------------------------ Robot.Check Services
| FAIL | 1 critical test, 0 passed, 1 failed 1 test total, 0 passed, 1 failed ============================================================================== Robot
| FAIL | 1 critical test, 0 passed, 1 failed 1 test total, 0 passed, 1 failed ============================================================================== Output: /opt/robot/logs/output.xml Log: /opt/robot/logs/log.html Report: /opt/robot/logs/report.html
有什么问题吗?谢谢
阅读错误消息告诉您的内容:
No keyword with name 'Split Function ${services}' found.
它认为测试试图调用关键字Split Function ${services}
。您没有使用该名称的关键字。你做的是一个名为Split Function
的关键字,它接受一个参数。因此,您需要使用正确的语法将参数传递给关键字。
换句话说,关键字和参数之间需要两个或更多空格:
Split Function ${services} # need at least two spaces before $