[英]Custom Python keyword for Robot Framework - Expected 0 arguments, got 1
I'm creating a Python keyword library using Squish for Qt for running a custom Qt application GUI tests with Robot Framework.我正在使用 Squish 为 Qt 创建一个 Python 关键字库,以使用 Robot Framework 运行自定义 Qt 应用程序 GUI 测试。 Currently I'm running Robot Framework 3.2.2 on Python 3.8.7 (and Squish 6.6.2) and I'm encountering issues with passing arguments from Robot to Python.
目前,我正在 Python 3.8.7(和 Squish 6.6.2)上运行 Robot Framework 3.2.2,并且在将 arguments 从 Robot 传递到 ZA7F5F35426B56741173Z923 时遇到问题。
In Python file called ClientKeywords.py I have following在名为 ClientKeywords.py 的 Python 文件中,我有以下内容
class ClientKeywords:
def start_client(launchMode):
if launchMode = "":
#Launch Client in default mode
elif launchMode = "logger":
#Launch Client with logging
In Robot file I'm using the keyword simply like在机器人文件中,我使用的关键字就像
Library ClientKeywords
*** Test Cases ***
Smoke Test
[Documentation] This is a smoke test
Start Client logger
When running the test I'm getting an error运行测试时出现错误
Keyword 'ClientKeywords.Start Client' expected 0 arguments, got 1.
关键字“ClientKeywords.Start Client”预期为 0 arguments,得到 1。
The issue additionally manifests so that some keyword arguments are simply not showing up when running the libdoc tool on the keyword file.该问题还表现出一些关键字 arguments 在关键字文件上运行 libdoc 工具时根本没有显示。 I haven't really been able to figure a pattern since some arguments are showing and some are not.
由于一些 arguments 正在显示,而有些则没有,我还没有真正想出一个模式。 For example:
例如:
drag_line_measurement(startY, dX, dY):
#Do stuff
click_on(intX, intY):
#Click stuff
show up in the generated document like following显示在生成的文档中,如下所示
Keyword![]() |
Arguments ![]() |
---|---|
Drag Line Measurement![]() |
startY, dX, dY![]() |
Click On![]() |
intY![]() |
It seems that there's some issue with how I'm using the class structure, as the library works mostly fine when the class definition is removed but that wouldn't be a viable long-term solution in this case - especially so when libdoc only documents the imported Squish python libraries instead of the actual library file without the class defined.似乎我如何使用 class 结构存在一些问题,因为当 class 定义被删除时,该库工作得很好,但在这种情况下这不是一个可行的长期解决方案 - 特别是当 libdoc 只记录文件时导入的 Squish python 库而不是未定义 class 的实际库文件。
You should change this你应该改变这个
def start_client(launchMode):
to至
def start_client(self, launchMode):
because it is a class member function.因为它是 class 成员 function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.