I have a django project, where I have written a unit-test, using the StaticLiveServerTestCase as shown in the example code below. I am using Selenium to execute the tests, and this works successfully on my local machine. However, when circle-ci executes my test, I am presented with a time out error.
2019-03-28 15:34:44,872 DEBUG selenium.webdriver.remote.remote_connection POST http://127.0.0.1:56804/session/sessid/url {"url": "http://localhost:37402/ja/accounts/login/", "sessionId": "sessid"}
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout
(Session info: chrome=67.0.3396.99)
(Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.4.0-141-generic x86_64)
At first I thought the error was due to selenium and circle-ci, so I changed my webdriver.get() command to call google . com instead of my own site, and the circle-ci container successfully calls to google.
self.web_driver.get('%s%s' % (self.live_server_url, reverse('login')))
So I was able to rule out a circle-ci / selenium issue.
Next, I considered the issue could be caused by celery. On the login page, celery is being polled, to check whether or not a particular task is being processed. In production, the celery server is called and returns its response as normal. In the circle-ci / unit test scenario, this call times out.
One diagnostic test I tried, was to simply return True, early from my celery task processing check - and if I do this, circle-ci does not time out and the tests are executed properly.
Does anyone have any ideas, how to make circle-ci and celery play nicely, via a unit-test scenario - implying that I do not want the unit-test to check the live celery server.
Below, is the example test-case code that I am using from the django-selenium documentation. Thanks for your help.
Django - Selenium Documentation
Selenium - Django Unit Test code
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.selenium = WebDriver()
cls.selenium.implicitly_wait(300)
def test_login(self):
self.selenium.get('%s%s' % (self.live_server_url, '/login/'))
username_input = self.selenium.find_element_by_name("username")
username_input.send_keys('myuser')
password_input = self.selenium.find_element_by_name("password")
password_input.send_keys('secret')
self.selenium.find_element_by_xpath('//input[@value="Log in"]').click()