automation - 机器人框架 - 未找到关键字 - 使用 IP 地址作为目标
问题描述
我收到一个“没有名称的关键字......”错误,如下所示。我认为这与我的测试用例引用 IP 地址有关,但不确定?
请参阅下面的测试代码和 CLI 输出,感谢帮助
*** Settings ***
Documentation Suite - Open Connections and do a simple comparison test
Suite Setup Device Open Connection @{TARGET}
Suite Teardown Device Close Connection @{TARGET}
Library OperatingSystem
Library /Users/xxx/Desktop/CI/RobotTestingFramework/Libraries/pybot_jrouter.py target=${TARGET} WITH NAME ${TARGET}
Library /Users/xxx/Desktop/CI/RobotTestingFramework/Libraries/iplib.py
Resource /Users/xxx/Desktop/CI/RobotTestingFramework/Resources/device_resources.robot
Resource /Users/xxx/Desktop/CI/RobotTestingFramework/Resources/version_resources.robot
*** Variables ***
${USERNAME} xxx
${PASSWORD} Juniper123
${path} ./Report
@{TARGET} 192.168.1.100
${OSversion} 12.1R1.9
*** Test Case ***
Check Software Version
[Documentation] Test - Version Check
[Tags] version
FOR ${target} IN @{TARGET}
Check Software Version ${target} ${OSversion}
END
检查版本软件 -
*** Settings ***
Resource /Users/xxx/Desktop/CI/RobotTestingFramework/Resources/device_resources.robot
Library String
Library Collections
Library XML
*** Keywords ***
Check Software Version
[ARGUMENTS] ${device} ${software-version}
${get-software-details} Command Executor ${device} show version xml //junos-version
Should Be Equal ${software-version} ${get-software-details} The Junos OS version is different than expected!
打开连接 -
*** Settings ***
Documentation A resource file with reusable keywords for 'executing the command in device',initiate device connection and tear down device connection.It can be used for any devices such as SWITCH,ROUTER,FIREWALL. NOTE: It has to be developed further to make it complete generic
*** Keywords ***
Device Open Connection
[Arguments] @{devices}
FOR ${device} IN @{devices}
Run Keyword ${device}.Open Connection
END
Check Version :: Suite - Open Connections and do a simple comparison test
==============================================================================
Check Software Version :: Test - Version Check | FAIL |
Parent suite setup failed:
No keyword with name '192.168.1.100.Open Connection' found.
解决方案
免责声明:我可以告诉你为什么它会抛出错误,但你可以改变它以使其得到修复——如果不知道最终目标、库等,很难推断出意图。
错误指出:
父套件设置失败:
找不到名称为“192.168.1.100.Open Connection”的关键字。
您的套件设置 - 错误的来源 - 是Device Open Connection @{TARGET}
,例如使用参数调用关键字列表“TARGET”的成员(例如扩展列表)。该关键字正在对其传递的所有参数进行循环,并且执行以下操作:
Run Keyword ${device}.Open Connection
,其中“设备”是当前循环的值。
内置Run Keyword
就是这样做的 - 它需要一个关键字名称并执行它。所以你有效地传递了“192.168.1.100.Open Connection”,并期待 - 什么?:) 执行此类关键字的框架?但是您还没有定义它,并且-该消息失败了。
这是我(至少)无法进一步提供帮助的时刻 - 这就是您看到此错误消息的原因,但是从这里获取它的位置 - :)。
也许,这些库中某处有一个方法/关键字“打开连接”,它需要 IP 地址;我不知道,我只是从这里开始猜测。
推荐阅读
- github - 如何模板 Zenodo 自动发布存档
- spring-boot - 带有千分尺 Elasticsearch 注册表的 Spring Boot 仅索引空文档
- c# - 如何检查工作表是否包含特定的宏
- python - 如何修复描述对象潜在客户时出现的“simple_salesforce.exceptions.SalesforceResourceNotFound”错误?
- javascript - 变量在 jQuery 迭代期间只找到一次
- python - 如何在数据框中绘制具有三列的无向图,形成 3 种不同类型的节点(三方)?
- c# - 尝试使用 Azure DevOps REST API 向工作项发布讨论“评论”时出错
- javascript - 如何使用 React 中的单独按钮关闭“折叠”中打开的“面板”?
- opencv - Emgu.CV.InRange 返回黑色图像
- java - 在Java中,构造函数中最终的字段赋值涉及哪些操作?