简体   繁体   中英

Use python script in robot framework

Please help to understand.

I have script (SplitModule.py) :

from robot.api.deco import keyword

@keyword('Split Function')
def splitfunction(string):
    print "atata"
    new_list = string.split(",")
    return new_list

And robot framework script test.txt :

*** Settings ***
Library           DiffLibrary
Library           String
Library           OperatingSystem
Library           Collections
Library       SplitModule.py

*** Test Cases ***
Example of calling a python keyword that calls a robot keyword
    Split Function ${services}

But I have a problem with function, there is out :

============================================================================== Robot ============================================================================== Robot.Check Services ============================================================================== Example of calling a python keyword that calls a robot keyword
| FAIL | No keyword with name 'Split Function ${services}' found. ------------------------------------------------------------------------------ Robot.Check Services
| FAIL | 1 critical test, 0 passed, 1 failed 1 test total, 0 passed, 1 failed ============================================================================== Robot
| FAIL | 1 critical test, 0 passed, 1 failed 1 test total, 0 passed, 1 failed ============================================================================== Output: /opt/robot/logs/output.xml Log: /opt/robot/logs/log.html Report: /opt/robot/logs/report.html

What's the problem? thanks

Read what the error message is telling you:

No keyword with name 'Split Function ${services}' found.

It thinks the test is trying to call the keyword Split Function ${services} . You don't have a keyword with that name. What you do have is a keyword named Split Function which takes an argument. Therefore, you need to use the proper syntax for passing the argument to the keyword.

In other words, you need two or more spaces between the keyword and the argument:

Split Function  ${services}  # need at least two spaces before $

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM