gpt4 book ai didi

django - 使用 Selenium webdriver 测试在 Travis CI 中使用 Sauce Labs 的 SSL 错误(Django 项目)

转载 作者:太空宇宙 更新时间:2023-11-03 13:22:00 24 4
gpt4 key购买 nike

尝试为我们的 Django 项目运行一些功能测试,但我们遇到了一个非常难以调试的错误。我们已尝试设置 sauce connect ,但我们的构建失败了。

你可以看到 results的构建,但这里是堆栈跟踪。

======================================================================
ERROR: test_page_load (quote_me.tests.FunctionalTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/python/3.6.3/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/opt/python/3.6.3/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/opt/python/3.6.3/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/opt/python/3.6.3/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/opt/python/3.6.3/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/opt/python/3.6.3/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/opt/python/3.6.3/lib/python3.6/http/client.py", line 1400, in connect
server_hostname=server_hostname)
File "/opt/python/3.6.3/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/opt/python/3.6.3/lib/python3.6/ssl.py", line 814, in __init__
self.do_handshake()
File "/opt/python/3.6.3/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/opt/python/3.6.3/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:777)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/travis/build/winecountry/quote-me/quote_me/tests.py", line 77, in setUp
self.selenium = webdriver.Remote(desired_capabilities=capabilities, command_executor="https://%s/wd/hub" % hub_url)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py", line 310, in execute
response = self.command_executor.execute(driver_command, params)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 466, in execute
return self._request(command_info[0], url, body=data)
File "/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/selenium/webdriver/remote/remote_connection.py", line 528, in _request
resp = opener.open(request, timeout=self._timeout)
File "/opt/python/3.6.3/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/opt/python/3.6.3/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/opt/python/3.6.3/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/opt/python/3.6.3/lib/python3.6/urllib/request.py", line 1361, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/opt/python/3.6.3/lib/python3.6/urllib/request.py", line 1320, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:777)>

错误将我指向 tests.py 中的第 77 行文件,这是

self.selenium = webdriver.Remote(desired_capabilities=capabilities, command_executor="https://%s/wd/hub" % hub_url)

这都是基于code from Travis , 你可以看到我们的 .travis.yml .

def setUp(self):
if "TRAVIS" in environ:
username = environ["SAUCE_USERNAME"]
access_key = environ["SAUCE_ACCESS_KEY"]
capabilities = {}
capabilities["tunnel-identifier"] = environ["TRAVIS_JOB_NUMBER"]
hub_url = "%s:%s@localhost:4445" % (username, access_key)
capabilities["build"] = environ["TRAVIS_BUILD_NUMBER"]
capabilities["tags"] = [environ["TRAVIS_PYTHON_VERSION"], "CI"]
self.selenium = webdriver.Remote(desired_capabilities=capabilities, command_executor="https://%s/wd/hub" % hub_url)
else:
self.selenium = webdriver.Safari()
super(FunctionalTestCase, self).setUp()

似乎是 SSL 证书问题,所以我查看了 no_ssl_bump_domains option但似乎没有帮助。还认为有些东西可能会不稳定,因为我们正在使用 Django manage.py runserver 命令。

如果您需要更多信息,请告诉我,我们非常感谢您的帮助!

最佳答案

通过更改修复此问题

self.selenium = webdriver.Remote(desired_capabilities=capabilities, command_executor="https://%s/wd/hub" % hub_url)

self.selenium = webdriver.Remote(desired_capabilities=capabilities, command_executor="http://%s/wd/hub" % hub_url)

如果您错过了,我们将 command_executor 更改为使用 http 而不是 https

关于django - 使用 Selenium webdriver 测试在 Travis CI 中使用 Sauce Labs 的 SSL 错误(Django 项目),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48236104/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com