参考
https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html
需要的插件
vscode 插件: robocrop
pip install -U wxPython==4.0.7.post2
pip install robotframework-SSHLibrary==3.4.0
python -m pip install robotframework
pip install robotframework-ftplibrary
注意函数空格的问题
No keyword with name ‘Run Shell Command ssh ${service}[0]-a “pkill ${service}[1]; date; pkill aim;” Timeout=30’ found. Did you try using keyword ‘CommonSBCResources.Run Shell Command’ or ‘OperatingSystem.Run’ and forgot to use enough whitespace between keyword and arguments?
怎么算是足够多的space?
list 实例/for
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#list-variables
${service_list}= Evaluate [[‘abc’, ‘df’, ‘ab’], [‘d’, ‘b’, ‘e’], [‘e’, ‘e’, ‘e’]]
FOR ${service} IN @{service_list}
${ip_output}= Execute ssh ${service}[0]-b “ip addr show abe”
END
引用library必须是在
必须在这个之后。
*** Settings ***
写自己的library
可以自己写自己的libaray,都是python的代码,对应的接口名称需要稍微改一下。在python里是小写和下划线,到了robot,就是下划线替换为空格,首字母大写。这样更接近自然语言?
#!/usr/bin/env python3
# NetworkUtil.py
from ipaddress import IPv4Network
class NetworkUtil:
def netmask_to_prefix(self, netmask): /// 调用的时候是写单词不用下滑线,头字母大写。
"""Change netmask to prefix
Args:
netmask: e.g.: "255.255.255.0"。
Returns:
prefix: e.g.:24.
"""
network = IPv4Network(f"0.0.0.0/{netmask}")
return network.prefixlen