RobotFramework学习-问题

RobotFramework,基于Python的自动化测试框架。近期学习中遇到过一些问题。

1.运行ride时,报错[ ERROR ] option --monitorcolors not recognized

原因:这是RobotFramework框架与一些扩展库的版本不兼容。

解决方案:使用 pip install --upgrade robotframework-ride  来更新到最新的版本。

2.运行时后台报错 

Traceback (most recent call last):
File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunnerplug
in.py", line 370, in OnTimer
self._test_runner.get_output_and_errors(self.get_current_profile())
File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunner.py"
, line 250, in get_output_and_errors
stdout, stderr, returncode = self._process.get_output(), \
File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunner.py"
, line 305, in get_output
return self._output_stream.pop()
File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunner.py"
, line 400, in pop
return result.decode('UTF-8')
File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb2 in position 592: invalid
start byte

原因: 在更新robotframework-ride前,都没有报这个错。更新后运行ride,就会出现,每运行一次,都会报此错,必须重新启动ride。分析报错信息,应该是编码的问题。

解决:网上找到很多遇到类似问题的,有的说是版本问题,有的是说在py脚本文件头部加上

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

有的说是要用Unicode("中文字符***") 。

寻着报错文件,一个个对着找到testrunnerplugin.py、testrunner.py、utf_8.py这几个文件,查看了对应行的代码,跟网友们给出的答案不太相符。有点无从修改。

在utf_8.py这个文件有这样一句:def decode(input, errors='strict'): 。

寻思着这个strict可能有问题,严格模式,大概对编码格式太过严苛。哈哈

最终解决方案:

还是决定通过UnicodeDecodeError: 'utf8' codec can't decode byte 0xb2百度一下,在stackoverflow找到一个。提到修改errors的赋值。原文地址:http://stackoverflow.com/questions/12468179/unicodedecodeerror-utf8-codec-cant-decode-byte-0x9c

改了后,成功解决了问题,没有再报该错了。

3.运行时报错

HTTP Error 403: Must access using HTTPS instead of HTTP
FAILED QTLibrary Importing test library 'QTLibrary' failed: ImportError: cannot
import name GLOBAL_VARIABLES
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py", lin
e 143, in _import
return __import__(name, fromlist=fromlist)
File "C:\Python27\lib\site-packages\robotframework_qtlibrary-1.0.0-py2.7.egg\Q
TLibrary\__init__.py", line 3, in <module>
from keywords import *
File "C:\Python27\lib\site-packages\robotframework_qtlibrary-1.0.0-py2.7.egg\Q
TLibrary\keywords\__init__.py", line 2, in <module>
from _logging import _LoggingKeywords
File "C:\Python27\lib\site-packages\robotframework_qtlibrary-1.0.0-py2.7.egg\Q
TLibrary\keywords\_logging.py", line 3, in <module>
from robot.variables import GLOBAL_VARIABLES

 

FAILED MyLibrary Importing test library 'MyLibrary' failed: ImportError: No modu
le named MyLibrary
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\robotide\lib\robot\utils\importer.py", lin
e 143, in _import
return __import__(name, fromlist=fromlist)

posted @ 2017-03-16 11:17  cheryl_wu  阅读(5106)  评论(3编辑  收藏  举报