![](/img/trans.png)
[英]Test Setup and Teardown for each test case in a test suite in Robot Framework using python
[英]Robot Framework: Suite Teardown fails when using Close All Browsers
我正在使用chromedriver , 机器人框架与SeleniumLibrary ,所有测试工作正常,但套件拆解失败。 我似乎无法找出原因。 非常感谢帮助。 日志显示:
家庭套房拆解失败:BadStatusLine:''
*** Settings ***
Suite Setup Open Database Connection
Test Setup Login
Suite Teardown Suite shutdown
*** Test cases ***
...
...
*** Keywords ***
Suite shutdown
Disconnect from Database
Close All Browsers
已安装的版本
我注销了导致BadStatusLine错误的原因,我希望这有助于找到解决方案
09:26:28.700 FAIL BadStatusLine: ''
09:26:28.700 DEBUG Traceback (most recent call last):
File "C:\Python27x86\lib\site-packages\SeleniumLibrary\__init__.py", line 372, in run_keyword
return DynamicCore.run_keyword(self, name, args, kwargs)
File "C:\Python27x86\lib\site-packages\SeleniumLibrary\base\robotlibcore.py", line 102, in run_keyword
return self.keywords[name](*args, **kwargs)
File "C:\Python27x86\lib\site-packages\SeleniumLibrary\keywords\browsermanagement.py", line 47, in close_all_browsers
self.drivers.close_all()
File "C:\Python27x86\lib\site-packages\SeleniumLibrary\keywords\webdrivertools.py", line 245, in close_all
driver.quit() File "C:\Python27x86\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 158, in quit
self.service.stop()
File "C:\Python27x86\lib\site-packages\selenium\webdriver\common\service.py", line 151, in stop
self.send_remote_shutdown_command()
File "C:\Python27x86\lib\site-packages\selenium\webdriver\common\service.py", line 127, in send_remote_shutdown_command
url_request.urlopen("%s/shutdown" % self.service_url)
File "C:\Python27x86\lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout) File "C:\Python27x86\lib\urllib2.py", line 429, in open
response = self._open(req, data)
File "C:\Python27x86\lib\urllib2.py", line 447, in _open
'_open', req) File "C:\Python27x86\lib\urllib2.py", line 407, in _call_chain
result = func(*args)
File "C:\Python27x86\lib\urllib2.py", line 1228, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python27x86\lib\urllib2.py", line 1201, in do_open
r = h.getresponse(buffering=True)
File "C:\Python27x86\lib\httplib.py", line 1136, in getresponse
response.begin()
File "C:\Python27x86\lib\httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "C:\Python27x86\lib\httplib.py", line 417, in _read_status
raise BadStatusLine(line)
你正在使用的硒版本可能导致这种情况。
要查看哪些版本的selenium支持您正在使用的python版本,请查看。 https://github.com/robotframework/SeleniumLibrary/blob/master/README.rst#support
*** Settings ***
Suite Setup Open Database Connection
Test Setup Login
Suite Teardown Suite shutdown
Library SeleniumLibrary
*** Test cases ***
...
...
*** Keywords ***
Suite shutdown
Disconnect from Database
Close All Browsers
快速修复将向您的套件拆分添加Run Keyword And Ignore Error
它仍然会执行有效的命令,但会跳过错误命令
*** Settings ***
Library Selenium2Library
Suite Teardown Run Keyword And Ignore Error Suite shutdown
*** Test Cases ***
Test Keyword
Open Browser http://google.com chrome
*** Keywords ***
Suite shutdown
Erro1234r # This should fail due to no keyword named Erro1234r, it skips this and closes all browsers
Close All Browsers
错误BadStatusLine: ''
从python的httplib传播 - http通信的核心模块(显而易见的是它的名字:)),并且来自selenium和浏览器webdriver之间通信中的错误。
它与Robot Framework的SeleniumLibrary / Selenium2Library没有任何联系 - 它只是一个包装器(我必须承认的一个非常好的包装)在selenium库上。
因此,在这个方向上查找错误 - 已安装的selenium
库的版本与安装的chromedriver
不chromedriver
- 一个发送到其他数据,这对于收件人来说是意外的。
我建议升级到两者的最新版本 - 当一个(明显)比另一个更新时,会发生这种打嗝。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.