[英]Robot Framework: Suite Teardown fails when using Close All Browsers
I'm using chromedriver , robotframework with SeleniumLibrary and all the tests works fine, but the suite teardown fails. 我正在使用chromedriver , 机器人框架与SeleniumLibrary ,所有测试工作正常,但套件拆解失败。 I cant seem to find out why. 我似乎无法找出原因。 Help would be greatly appreciated. 非常感谢帮助。 Log shows: 日志显示:
Parent suite teardown failed: BadStatusLine: '' 家庭套房拆解失败: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
Installed versions 已安装的版本
I logged out what caused the BadStatusLine error, I hope this helps to find the solution 我注销了导致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)
The version of selenium you are using could be causing this. 你正在使用的硒版本可能导致这种情况。
To see what versions of selenium support what python version you are using check out. 要查看哪些版本的selenium支持您正在使用的python版本,请查看。 https://github.com/robotframework/SeleniumLibrary/blob/master/README.rst#support 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
A quick fix would be to add Run Keyword And Ignore Error
to your Suite Teardown it will still execute the commands that are valid but will skip the error command something like this works 快速修复将向您的套件拆分添加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
The error BadStatusLine: ''
propagates from python's httplib - the core module for http communication (as is obvious by its name :)), and comes from error in the communcation between selenium and the webdriver for the browser. 错误BadStatusLine: ''
从python的httplib传播 - http通信的核心模块(显而易见的是它的名字:)),并且来自selenium和浏览器webdriver之间通信中的错误。
It has no connection with Robot Framework's SeleniumLibrary/Selenium2Library - it is just a wrapper (a very good one I must admit) over the selenium library. 它与Robot Framework的SeleniumLibrary / Selenium2Library没有任何联系 - 它只是一个包装器(我必须承认的一个非常好的包装)在selenium库上。
So look for the error in that direction - the version of your installed selenium
library does not work well with the installed chromedriver
- one sent to the other data, that was unexpected for the recipient. 因此,在这个方向上查找错误 - 已安装的selenium
库的版本与安装的chromedriver
不chromedriver
- 一个发送到其他数据,这对于收件人来说是意外的。
I'd suggest to upgrade to the latest versions of both - this hiccups do happen when one is (significantly) newer than the other. 我建议升级到两者的最新版本 - 当一个(明显)比另一个更新时,会发生这种打嗝。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.