简体   繁体   English

机器人框架的自定义 Python 关键字 - 预期为 0 arguments,得到 1

[英]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 Arguments
Drag Line Measurement拖线测量 startY, dX, dY开始Y, 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.

相关问题 如果在Robot Framework中用作自定义关键字,Python模块将无法正常工作 - Python module does not work as expected, if used as custom keyword in Robot Framework 我们在机器人框架中收到以下错误“关键字'OperatingSystem.Create File'在命名参数之后得到位置参数” - We get the following error in Robot Framework “Keyword 'OperatingSystem.Create File' got positional argument after named arguments” Robot Framework-从自定义关键字返回值 - Robot Framework - return a value from custom keyword Robot Framework自定义关键字仅在测试设置中 - Robot Framework custom keyword only in Test Setup 调试机器人框架python关键字库 - Debugging robot framework python keyword libraries 在 Robot Framework 中将 python 文件作为关键字运行时出现问题 - Trouble running python file as a keyword in Robot Framework 自定义关键字机器人框架 selenium webdriver python“对象没有属性 'get_attribute'” - Custom keyword robot framework selenium webdriver python "object has no attribute 'get_attribute' " 使用 Robot Framework 自定义关键字从 Python 脚本返回列表值 - Return list values from Python Script using Robot Framework custom Keyword Python Robot Framework将参数传递给函数 - Python Robot Framework Pass arguments to a function Robot Framework中的关键字是什么? - What is a keyword in Robot Framework?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM