1
votes

I'm creating a Python keyword library using Squish for Qt for running a custom Qt application GUI tests with Robot Framework. 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.

In Python file called ClientKeywords.py I have following

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.

The issue additionally manifests so that some keyword arguments are simply not showing up when running the libdoc tool on the keyword file. I haven't really been able to figure a pattern since some arguments are showing and some are not. 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.

1
I think you should change this def start_client(launchMode): to def start_client(self, launchMode): because it is a class member function.Bence Kaulics
Oh, I didn't realise that every function inside the class requires the self argument. This however fixes the issue, so if you create an answer I'd be happy to accept it.Morkkis

1 Answers

3
votes

You should change this

def start_client(launchMode): 

to

def start_client(self, launchMode):

because it is a class member function.