robot 关键词

关键词

  • 创建resource类型的userkey.robot文件
*** Keyword ***
mykeyworkd      
    [Arguments]        ${input}
    Log    ${input}    
    
  • 使用时引入
*** Settings ***
Resource    userkey.robot

*** Test Cases ***
test
    mykeyworkd    hello world

python子函数引入

  • 创建任意python文件
#conding=utf-8

def addNum(num1,num2):
    return int(num1)+int(num2)
  • 在需要使用的地方引入library
*** Settings ***

*** Test Cases ***
test
    Import Library    /Users/peter/Desktop/hlpx/03test/good/myrobot/mygod/apitestsuite/userpython.py
    ${ret}         addNum     19    4    

自定义python库

  • 在python库目录编写库文件
➜  myCustomLibrary pwd
/Library/Python/2.7/site-packages/myCustomLibrary
➜  myCustomLibrary cat myclass.py
class MyClass(object):
    def __init__(self):
        pass

    def printMsg(self,msg):
        print "hello "+msg
➜  myCustomLibrary cat __init__.py
from myclass import MyClass

class myCustomLibrary(MyClass):
    ROBOT_LIBRARY_SCOPE = 'GLOBAL'
  • 在robot中引用
*** Settings ***
Library        myCustomLibrary


*** Test Cases ***
test
    printMsg        god
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容