看了网上一些教程,导入自定义系统关键字
在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