我有需要转换为Robot Framework的Python代码。
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=host, username=user, password=passwd, port=port)
stdin, stdout, stderr = client.exec_command(command, timeout=15)
stdout_bin = stdout.read()
stdout_str = bytes(stdout_bin).decode()
# print(stdout_str)
flag_corect_retriev = 0
client.close()
if value is not None:
if str(stdout_str).find(value) != -1:
print(f"{value}.\tFounded.")
return 1
else:
print(f"{value}.\tNot founded.")
return 0
else:
return stdout_str
是否可以使其在Robot Framework中工作?
我对Robot Framework了解不多。
如果从机器人测试用例调用 python 代码适合您,那么这是一个替代解决方案:
这将允许从 Robot 测试用例调用 python 代码, 代码就变成这样了:
from robot.api.deco import keyword
@keyword('Name Of New keyword'):
def name_of_new_keyword(arg1, arg2):
##### your python code goes here ..
*** Settings ***
Library path_to_your_python_library/python_file_name.py
*** Test Cases ***
TC_YOUR_ROBOT_TEST
[Setup]
Name Of New Keyword arg1_value_ arg2_value
[Teardown]
检查是否需要更新参数值或从 python 方法和机器人测试中删除它们。 我建议您查看官方文档以获取有关RobotFramework的更多知识:https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html