仓库自定义库

这里以Selenium2Library库进行举例说明:
编写一个自定义仓库类(与库文件夹名一致),继承关键字类,指定范围和版本即可。
需要声明__init__。

import os
from keywords import *
from version import VERSION
from utils import LibraryListener

__version__ = VERSION

class Selenium2Library(
    _LoggingKeywords,
    _RunOnFailureKeywords,
    _BrowserManagementKeywords,
    _ElementKeywords,
    _TableElementKeywords,
    _FormElementKeywords,
    _SelectElementKeywords,
    _JavaScriptKeywords,
    _CookieKeywords,
    _ScreenshotKeywords,
    _WaitingKeywords,
    _AlertKeywords
):
    """库说明信息"""
    ROBOT_LIBRARY_SCOPE = 'GLOBAL'
    ROBOT_LIBRARY_VERSION = VERSION

设置仓库参数
这里以为例:这里导入仓库时就可以设置隐式等待时间。

def __init__(self,
                 timeout=5.0,
                 implicit_wait=0.0,
                 run_on_failure='Capture Page Screenshot',
                 screenshot_root_directory=None
    ):


注意:修改文件后要记得删除pyc文件并重启RIDE

posted on 2019-07-15 10:02  liehen2046  阅读(303)  评论(0编辑  收藏  举报