I'm running some basic functional web test with the Selenium web driver and I'm noticing this error in two of my functional web test cases. The test cases all pass at the end but I get this in the console:
Exception happened during processing of request from ('127.0.0.1', 1169)
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host
Traceback (most recent call last):
File "C:\dev\django-projects\barbwire\venv\lib\site-packages\django\test\testcases.py", line 981, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Python27\Lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "C:\Python27\Lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\dev\django-projects\barbwire\venv\lib\site-packages\django\core\servers\basehttp.py", line 139, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Python27\Lib\SocketServer.py", line 638, in __init__
self.handle()
File "C:\Python27\Lib\wsgiref\simple_server.py", line 116, in handle
self.raw_requestline = self.rfile.readline()
File "C:\Python27\Lib\socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host
Traceback (most recent call last):
File "C:\dev\django-projects\barbwire\venv\lib\site-packages\django\test\testcases.py", line 981, in _handle_request_noblock
self.process_request(request, client_address)
File "C:\Python27\Lib\SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "C:\Python27\Lib\SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\dev\django-projects\barbwire\venv\lib\site-packages\django\core\servers\basehttp.py", line 139, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "C:\Python27\Lib\SocketServer.py", line 638, in __init__
self.handle()
File "C:\Python27\Lib\wsgiref\simple_server.py", line 116, in handle
self.raw_requestline = self.rfile.readline()
File "C:\Python27\Lib\socket.py", line 447, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 1170)
----------------------------------------
Destroying test database for alias 'default'...
Here's an example of one of the test cases:
def test_can_join_main_site(self):
self.browser.get(self.live_server_url)
self.browser.find_element_by_link_text('Register').click()
time.sleep(5)
self.browser.find_element_by_name('submit').click()
time.sleep(5)
It runs to completion but dumps the above exception. The idea is to test a simple registration page. After clicking the submit button the page re-displays and prompts the user to fill out additional form fields. As expected and everything appears to work correctly but why the errors? Am I missing something?
Replacing localhost
with 127.0.0.1 did not work for me, and adding sleep
just slows the test down. I was able to get rid of the error by calling refresh before quitting the browser:
from selenium import webdriver
browser = webdriver.Firefox()
# do stuff with browser
browser.refresh()
browser.quit()
In my case it was the loading of static files in <link>
and <script>
tags that was causing the problem. But it went away when I added refresh
before quitting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With