I am trying to set up a LiveServerTestCase with Django 1.10.4. Whenever I run my tests the the browser opens up hangs and can't reach localhost. My frontend is a separate angular/react app. So, I build my static assets using grunt build and then run collectstatic. Below is the code for my tests.
from django.test.testcases import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
class ChromeTestCase(LiveServerTestCase):
@classmethod
def setUpClass(cls):
super(ChromeTestCase, cls).setUpClass()
cls.driver = webdriver.Chrome('/path/to/chromedriver')
cls.driver.implicitly_wait(10)
cls.wait = WebDriverWait(cls.driver, 10)
@classmethod
def tearDownClass(cls):
cls.driver.quit()
super(ChromeTestCase, cls).tearDownClass()
def test_user_sign_up_from_form(self):
self.driver.get('%s%s' % (self.live_server_url, '/'))
self.wait.until(EC.presence_of_element_located((By.XPATH, '//input[@id="email"]')))
email_input = self.driver.find_element_by_xpath(
'//input[@id="email"]')
email_input.send_keys("test@gmail.com")
password_input = self.driver.find_element_by_xpath(
'//input[@id="password"]')
password_input.send_keys("secret")
signup_button = self.driver.find_elements_by_xpath(
'//*[@id="signup_button"]')
signup_button.click()
url = self.live_server_url + '/home'
self.assertEquals(self.driver.current_url, url)
Does anyone know why my tests can't reach the test server?
Also, The url my test server creates is https.