[英]Selenium connection time out when initializing driver
I've written a Django (version 1.3, sadly) management command to connect to BrowserStack with Selenium and am going to be using to run integration tests. 我写了一个Django(版本1.3,遗憾地)管理命令,用Selenium连接到BrowserStack,我将用于运行集成测试。 (I've had to write a custom management command to get around the fact that we use AskBot within this site and it messes up the Django testing framework in some funny ways; otherwise I would simply use the testing framework.) (我必须编写一个自定义管理命令来解决我们在这个站点中使用AskBot的事实,它以一些有趣的方式弄乱了Django测试框架;否则我只是使用测试框架。)
Gist of the script is here https://gist.github.com/cellofellow/7491221 . 脚本的要点在这里https://gist.github.com/cellofellow/7491221 。 This is a port of an earlier script that just ran unittest directly without any Django context. 这是一个早期脚本的端口,只是在没有任何Django上下文的情况下直接运行unittest。
What happens is that when ran, I get a traceback like so: 会发生什么事情,当我跑步时,我会得到一个跟踪:
./manage.py browserstack signup
Browser: IE
Browser Version: 10.0
Operating System: Windows
OS Version: 7
E
======================================================================
ERROR: runTest (apps.common.management.commands.browserstack.SignUpBasic)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jgardner/izeni/doterra_pro/apps/common/management/commands/browserstack.py", line 46, in setUp
desired_capabilities=self.caps)
File "/home/jgardner/.virtualenvs/doterra_pro/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 71, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/home/jgardner/.virtualenvs/doterra_pro/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 113, in start_session
'desiredCapabilities': desired_capabilities,
File "/home/jgardner/.virtualenvs/doterra_pro/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 162, in execute
response = self.command_executor.execute(driver_command, params)
File "/home/jgardner/.virtualenvs/doterra_pro/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 355, in execute
return self._request(url, method=command_info[0], data=data)
File "/home/jgardner/.virtualenvs/doterra_pro/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 402, in _request
response = opener.open(request)
File "/usr/lib/python2.7/urllib2.py", line 410, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 442, in error
result = self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 897, in http_error_401
url, req, headers)
File "/usr/lib/python2.7/urllib2.py", line 872, in http_error_auth_reqed
response = self.retry_http_basic_auth(host, req, realm)
File "/usr/lib/python2.7/urllib2.py", line 885, in retry_http_basic_auth
return self.parent.open(req, timeout=req.timeout)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 1214, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "/usr/lib/python2.7/urllib2.py", line 1187, in do_open
r = h.getresponse(buffering=True)
File "/usr/lib/python2.7/httplib.py", line 1045, in getresponse
response.begin()
File "/usr/lib/python2.7/httplib.py", line 409, in begin
version, status, reason = self._read_status()
File "/usr/lib/python2.7/httplib.py", line 365, in _read_status
line = self.fp.readline(_MAXLINE + 1)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
timeout: timed out
----------------------------------------------------------------------
Ran 1 test in 5.201s
FAILED (errors=1)
In BrowserStack an instance is started but because whatever happens next can't connect, it simply runs for a minute or so and then exits. 在BrowserStack中启动一个实例但是因为接下来发生的任何事情无法连接,它只运行一分钟左右然后退出。
The script it was ported from didn't have this problem. 它移植的脚本没有这个问题。 What may be causing it? 可能是什么造成的?
事实证明我只需要设置socket.setdefaulttimeout(60)
在这个代码库中有几十次对socket.setdefaulttimeout
的调用,包括依赖项和我们自己的代码,所以谁知道实际设置的是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.