3

I'm using chromedriver, robotframework with SeleniumLibrary and all the tests works fine, but the suite teardown fails. I cant seem to find out why. Help would be greatly appreciated. Log shows:

Parent suite teardown failed: 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
  • robot framework 3.1.1
  • python 2.7.12
  • SeleniumLibrary 3.3.1
  • Selenium 3.141.0

I logged out what caused the BadStatusLine error, I hope this helps to find the solution

    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)
Lorand Fazakas
  • 105
  • 2
  • 7

3 Answers3

1

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. 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
Justin Wilkins
  • 341
  • 2
  • 15
1

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

*** 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
AutoTester213
  • 2,714
  • 2
  • 24
  • 48
0

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.
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.

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.
I'd suggest to upgrade to the latest versions of both - this hiccups do happen when one is (significantly) newer than the other.

Todor Minakov
  • 19,097
  • 3
  • 55
  • 60
  • I cannot upgrade Python to the latest version because its company policy. I tried to downgrade the chromedriver to 2.4.3 since its the latest which works with chrome 71.0. Still the same error unfortunately. By any chance can architectural differences cause these kinds of error? – Lorand Fazakas Jan 07 '19 at 11:40
  • I'm talking about the selenium _library_, not the python itself - can you update it? The command to do so is usually "`pip install --upgrade selenium`". An earlier version will most probably not work ok with chromedriver. – Todor Minakov Jan 07 '19 at 11:48
  • Its already the latest (3.141.0). Running the command says `Requirement already up-to-date: selenium in c:\python27\lib\site-packages (3.141.0)` `Requirement already satisfied, skipping upgrade: urllib3 in c:\python27\lib\site-packages (from selenium) (1.24.1)` – Lorand Fazakas Jan 07 '19 at 11:54