robotframework学习2-导入HttpLibrary.HTTP报错

虽然搭建robotframework环境变得超级简单了,但是在导入HttpLibrary.HTTP的时候报错了
报错信息如下所示:

20200724 19:49:21.534 WARN): Importing test library "Httplibrary.HTTP" failed 

Traceback (most recent call last):
Importing test library 'ttpLibrary.HTTP' failed: SyntaxError: invalid syntax(_ init_ _py, line 16)
Traceback (most recent call last);:
File "E:\Program Files (x86)\Python3\lib\site-packages\robotide\lib\robot\utis\importer.py" line 153, in. import
return_ import_ (name, fromlist=fromlist)
PYTHONPATH:
E:\Program Files (x86)\Python3\python37.zip
E:\Program Files (x86)\Python3\DLLs
E:\Program Files (x86)\Python3\lib
E:\Program Files (x86)\Python3
E:\Program Files (x86)\Python3\ib\site-packages
E:\Program Files (x86)\Python3\lib\site-packages\win32
E:\Program Files (x86)\Python3\lib\site-packages\win32\ib
E:\Program Files (x86)\Python3\lib\site-packages\Pythonwin
E:\Program Files (x86)\Python3\lib\site-packages\robotide\spec
E:\Program Files (x86)\Python3\lib\site-packages\robotide\lib
E:\Program Files (x86)\Python3\libsite-packages\robotide\contribtestrnne../lib
E:\Program Files (x86)\Python3\libsite-packages\robotide\contribtestrune./lib
File "E:\Program Files (x86)\Python3\Lib\site-packages\robotide\spec\librarymanager.py", line 87, in fetch keywords
	return get. import result(path, library. args)
File "E:\Program Files (x86)\Python3\Lib\site-packages\robotide\spec\libraryfetcher.py", line 24, in get import result
	lib = robotapi.TestLibrary(path, args)
File "E:\Program Files (x86)\Python3\Lib\site-packages\robotide\lib\robot\running\testlibraries.py". line 50, in TestLibrary
	return source=True)
File "E:\Program Files (x86)\Python3\Lib\site-packages\robot\utils\importer.py". line 72, in import. class _or module
	self. raise import. failed(name, err)
File "E:\Program Files (x86)\Python3\Lib\site-packages\robot\utils\importer.py. line 109, in. raise import failed
	raise DataError('\n' .join(msg))

经过查阅资料发现是版本不兼容导致的。
解决方法:
1.检查livetest,json是否已成功安装(检验方法就是使用import可以导入成功);
在这里插入图片描述
2.修改__init__.py (文件路径:E:\Python37\Lib\site-packages\HttpLibrary)
将from urlparse import urlparse 修改为from urllib.parse import urlparse
将except ValueError, e修改为 except ValueError as e (共两处)
3.重启ride,导入成功(HttpLibrary.HTTP字体显示黑色即代表成功,若是红色代表失败)。
robotframework学习2-导入HttpLibrary.HTTP报错_第1张图片

你可能感兴趣的:(RobotFramework)