Added test for submitting form without filling in required fields

This commit is contained in:
Naomi 2018-10-04 09:43:11 +01:00
parent 7e7d1d1d8a
commit 19dac7ac8b

View File

@ -32,7 +32,7 @@ class SeleniumTest(LiveServerTestCase):
chrome_options.add_argument('--no-sandbox')
# comment out this next line in order to see the tests running in a browser.
# But be sure to put it back before comitting, or gitlab CI will fail.
chrome_options.add_argument('--headless')
#chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
cls.sl = webdriver.Chrome(chrome_options=chrome_options)
cls.sl.implicitly_wait(TIMEOUT)
@ -87,6 +87,19 @@ class MapTest(SeleniumTest):
)
self.case_study.save()
def test_form_will_show_error(self):
self.user = User.objects.create_superuser(username='test', password='test', email='test@example.com');
self._open('/en-gb/case-study/create/long');
self.sl.find_element_by_id('id_username').send_keys('test');
self.sl.find_element_by_id('id_password').send_keys('test');
self.sl.find_element_by_css_selector('input[type="submit"]').click()
# navigate to the last tab, where the submit button is
self.sl.find_element_by_css_selector('a[href="#uploads"]').click()
# click submit without filling in any fields
self.sl.find_element_by_id('submit-id-submit').click()
error_message = self.sl.find_element_by_class_name('has-error')
self.assertTrue(error_message.is_displayed())
def test_map(self):
self._open('/')
WebDriverWait(self.sl, 5).until(