在使用Python完成selenium测试后抛出[HTTPError:HTTP错误503:服务不可用]错误

 self.driver.quit()
  File "C:\Python27\lib\site-packages\selenium-2.40.0-py2.7.egg\selenium\webdriver\chrome\webdriver.py", line 82, in quit
    self.service.stop()
  File "C:\Python27\lib\site-packages\selenium-2.40.0-py2.7.egg\selenium\webdriver\chrome\service.py", line 97, in stop
    url_request.urlopen("http://127.0.0.1:%d/shutdown" % self.port)
  File "C:\Python27\lib\urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 410, in open
    response = meth(req, response)
  File "C:\Python27\lib\urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python27\lib\urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)

HTTPError: HTTP Error 503: Service Unavailable

最佳答案 这种情况是否只发生在Chrome上?我遇到了一个产生完全相同的堆栈跟踪的
similar issue(尽管有407而不是503),所以我很想知道相同的解决方案是否会对此有所帮助.

导航到控制面板>互联网选项> “连接”标签> LAN设置>高级.然后,将127.0.0.1插入“例外”框.在我的情况下,这足以防止在调用.quit()时发生崩溃.

点赞