Robot Framework测试脚本因SSLError而失败

时间:2016-03-01 15:18:21

标签: python api automation openssl robotframework

我编写了.tsv格式的Robot Framework测试脚本来测试Web服务/ API。当我开始收到以下错误时,一切都工作正常(可能是因为Robot Framework的新更新):

  

SSLError :("糟糕的握手:SysCallError(-1,'意外的EOF')",)

此错误会一直弹出测试脚本中的以下代码:

${headers}=  Create Dictionary Content-Type application/json  Accept application/json
RequestsKeywords.Get Request httpbin ${url} headers=${headers} //ERROR SHOWS FOR THIS STATEMENT

我确实得到了这个错误的详细回溯,如下所示:

Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/RequestsLibrary/RequestsKeywords.py", line 298, in get_request
    session, uri, params, headers, redir, timeout)
  File "/Library/Python/2.7/site-packages/RequestsLibrary/RequestsKeywords.py", line 801, in _get_request
    cookies=self.cookies)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 480, in get
    return self.request('GET', url, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/adapters.py", line 447, in send
    raise SSLError(e, request=request)

我的系统配置:

Mac OS X (10.11.3)
Python (2.7.10)
openssl (1.0.2f)
requests (2.9.1)
robotframework (3.0)
robotframework-httplibrary (0.4.2)
robotframework-requests (0.4.4)
robotframework-ride (1.5.2.1)
robotframework-sshlibrary (2.1.2)
pyOpenSSL (0.15.1)

如何解决此问题?

2 个答案:

答案 0 :(得分:3)

你们都是最新的,所以有两种可能性:

  • 由于信任链中断,握手并不顺利。从底部开始并进行处理。你在局域网上测试吗?证书是最新的吗?您是否可以从您的位置和其他人访问该网站而不会出现错误? SSL labs显示任何内容?防火墙规则怎么样?
  • 最近的更新中有a bug。根据我的经验,OpenSSL报告是由连接问题引起的,而不是模糊的软件问题 - 这两者的可能性较小。

答案 1 :(得分:1)

尝试安装请求[安全]而不是请求。它使用PyOpenSSL,它比OpenSSL更好: pip install requests[security] vs pip install requests: Difference