I am getting this error with Django
RuntimeError: Failed to shutdown the live test server in 2 seconds. The server might be stuck or generating a slow response.
I am trying to run a simple test on a menu on my website. The menu is in an accordion style (scroll down to Example under the overview menu. An accordion is the thing in the Demo, where menus appear and disappear according to how you click them: http://docs.jquery.com/UI/Accordion#overview)
When one of the menus open, a text box for searching is present. What I’m trying to do is to press that button, then enter some values and click ‘Enter’ to go see the search results.
CODE
from django.test import LiveServerTestCase
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
import time
class SeleniumTests(LiveServerTestCase):
fixtures = ['testData.json',]
@classmethod
def setUpClass(cls):
cls.driver = WebDriver()
super(SeleniumTests, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(SeleniumTests, cls).tearDownClass()
cls.driver.quit()
def test_example(self):
#load the site
self.driver.get('%s%s' % (self.live_server_url, '/testingDB/'))
#find the accordion button
elem1 = self.driver.find_element_by_id("search_button")
#click it
elem1.click()
#wait a little bit so the accordion loads
self.driver.implicitly_wait(5)
#could've also used this command ->time.sleep(1)
#find the element that now appeared
elem = self.driver.find_element_by_name("q")
#enter the search query and press enter
elem.send_keys("selenium" + Keys.RETURN)
#assert that a new page loaded, with Search in the title
assert "Search" in self.driver.title
The test works great, but Django gives me the error. If I shorten the time too much, then selenium won’t be able to find the search box, and it claims
Element is not currently visible and so may not be interacted with
I don’t know how to avoid the live test server error. (Django information obtained from https://docs.djangoproject.com/en/dev/topics/testing/#django.test.LiveServerTestCase )
Additional Information
This is the menu:
Part 1

Then click ‘Search’ and the below appears in about 0.5 seconds.
Part 2

The error you are seeing is associated with the clean-up code found in
SeleniumTests.tearDownClass(cls). Within that method, if you callcls.driver.quit()before you callsuper(SeleniumTests, cls).tearDownClass()the error will go away.