简体   繁体   English

机器人框架:使用“关闭所有浏览器”时,套件拆解失败

[英]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 已安装的版本

  • chromedriver 2.45.615291 chromedriver 2.45.615291
  • robot framework 3.1.1 机器人框架3.1.1
  • python 2.7.12 python 2.7.12
  • SeleniumLibrary 3.3.1 SeleniumLibrary 3.3.1
  • Selenium 3.141.0 Selenium 3.141.0

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库的版本与安装的chromedriverchromedriver - 一个发送到其他数据,这对于收件人来说是意外的。
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.

相关问题 使用 python 对 Robot Framework 中的测试套件中的每个测试用例进行测试设置和拆卸 - Test Setup and Teardown for each test case in a test suite in Robot Framework using python 在 Robot Framework 中的 Suite Teardown 之前解析 output.xml - Parse output.xml before Suite Teardown in Robot Framework 有什么方法可以减少 Robot Framework 中的套件设置/拆卸和测试设置/拆卸样板? - Any way to reduce suite setup/teardown and test setup/teardown boilerplate in Robot Framework? Robot Framework 中的拆解操作 - Teardown action in Robot Framework 使用多线程时关闭所有带有 selenium 的浏览器 - Close all browsers with selenium when using multithreads "ROBOT FRAMEWORK:如何仅在测试用例失败时才执行测试拆卸?" - ROBOT FRAMEWORK: How to make test teardown execute only if test case fails? 无法使用“AND”条件为机器人框架中的多个变量设置套件变量 - Unable to Set Suite Variable for multiple variables in robot framework using "AND" condition 无法使用 Robot Framework 的 --Variable 为不同的浏览器运行 - Unable to run for different browsers using --Variable of Robot Framework 对嵌套文件夹结构机器人框架中的多个测试套件使用通用套件设置和套件拆解 - Use common Suite setup and Suite teardown for several test suites in a nested folder structure robot framewrok 测试用例失败时跳过拆卸 - skip teardown when testcase fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM