• RobotFramework系统关键字解决导入报错robot framework Importing test library "CustomLibrary" failed


    看了网上一些教程,导入自定义系统关键字

    在Libsite-packages目录下创建自定义文件夹CustomLibrary

    在CustomLibrary下面创建runbat.py,写入关键字

    在CustomLibrary下面创建__init__.py,供robotframework加载使用

    结果ride显示导入的CustomLibrary是红色(导入失败)

    查看日志:Ride中,查看日志Tools-->View Ride Logs

    20190823 15:35:38.329 [WARN]: Importing test library "CustomLibrary" failed

    Traceback (most recent call last):
    Importing test library 'CustomLibrary' failed: ModuleNotFoundError: No module named 'runbat'
    Traceback (most recent call last):
    File "D:9998Python37libsite-packages obotidelib obotutilsimporter.py", line 153, in _import
    return __import__(name, fromlist=fromlist)
    File "D:9998Python37libsite-packagesCustomLibrary\__init__.py", line 1, in <module>
    from runbat import Runbat
    PYTHONPATH:
    D:9998Python37Scripts
    D:9998Python37python37.zip
    D:9998Python37DLLs
    D:9998Python37lib
    D:9998Python37
    D:9998Python37libsite-packages
    D:9998Python37libsite-packagespip-19.1.1-py3.7.egg
    D:9998Python37libsite-packageswin32
    D:9998Python37libsite-packageswin32lib
    D:9998Python37libsite-packagesPythonwin
    D:9998Python37libsite-packages obotidespec
    D:9998Python37libsite-packages obotidelib
    D:9998Python37libsite-packages obotidecontrib estrunner../../lib
    D:9998Python37libsite-packages obotidecontrib estrunner../../lib
    File "D:9998Python37libsite-packages obotidespeclibrarymanager.py", line 87, in _fetch_keywords
    return get_import_result(path, library_args)
    File "D:9998Python37libsite-packages obotidespeclibraryfetcher.py", line 24, in get_import_result
    lib = robotapi.TestLibrary(path, args)
    File "D:9998Python37libsite-packages obotidelib obot unning estlibraries.py", line 50, in TestLibrary
    return_source=True)
    File "D:9998Python37libsite-packages obotidelib obotutilsimporter.py", line 72, in import_class_or_module
    self._raise_import_failed(name, err)
    File "D:9998Python37libsite-packages obotidelib obotutilsimporter.py", line 109, in _raise_import_failed
    raise DataError(' '.join(msg))

    解决办法:

    发现在pythonpath中只到D:9998Python37libsite-packages

    于是,在__init__.py中修改导入方式,

    from runbat import Runbat   ---->
    from CustomLibrary.runbat import Runbat
  • 相关阅读:
    Windows 和Linux 误删除后的恢复
    AWS 使用总结
    20180814 错误分析
    你必须知道的互联网协议详解
    linux常用命令和关闭防火墙
    Nginx之ngx_http_fastcgi_module模块详解
    nginx 限制ip
    nginx allow 多个ip & ipv4的网段表示方法解析
    从Nginx的Web请求处理机制中剖析多进程、多线程、异步IO
    剑指offer:二叉树的深度
  • 原文地址:https://www.cnblogs.com/james-danni/p/11400421.html
Copyright © 2020-2023  润新知