class MySeleniumTests(LiveServerTestCase):
def setUp(self):
self.selenium = WebDriver()
settings.CSRF_COOKIE_SECURE = False
settings.SESSION_COOKIE_SECURE = False
super(MySeleniumTests, self).setUp()
def tearDown(self):
self.selenium.quit()
super(MySeleniumTests, self).tearDown()
def test_register(self):
selenium = self.selenium
# Opening the link we want to test
selenium.get(self.live_server_url)
selenium.execute_script("return openLoginModal()")
time.sleep(2)
selenium.find_element_by_id('register-now').click()
time.sleep(1)
first_name = selenium.find_element_by_id('name')
first_name.send_keys("test_firstname")
last_name = selenium.find_element_by_id('lname')
last_name.send_keys("test_lastname")
email = selenium.find_element_by_id('email')
email.send_keys("test@gmail.com")
mobile = selenium.find_element_by_id('phone')
password = selenium.find_element_by_id('password')
password.send_keys('123456')
mobile.send_keys("0123456789")
primary_address =
selenium.find_element_by_id('primary_address')
primary_address.send_keys("primary address")
secondary_address =
selenium.find_element_by_id('secondary_address')
secondary_address.send_keys("secondary address")
select = Select(selenium.find_element_by_id('landmarkInput'))
select.select_by_visible_text('Other')
selenium.find_element_by_id('datepicker').click()
time.sleep(1)
submit = selenium.find_element_by_id('signup-button')
submit.send_keys(Keys.RETURN)
time.sleep(20)
в html формы регистрации есть csrf, который отлично работает на производстве
{% csrf_token%}
Во время выполнения теста при отправке формы токен csrf отсутствуетв шапке в пост звонке.
Любая помощь будет оценена.