diff --git a/RIGS/test_functional.py b/RIGS/test_functional.py index ab0f1e2e..706084cd 100644 --- a/RIGS/test_functional.py +++ b/RIGS/test_functional.py @@ -17,9 +17,9 @@ class UserRegistrationTest(LiveServerTestCase): def test_registration(self): # Navigate to the registration page self.browser.get(self.live_server_url + '/user/register/') - self.browser.implicitly_wait(3) + #self.browser.implicitly_wait(3) title_text = self.browser.find_element_by_tag_name('h3').text - self.assertIn("User Registration", tilte_text) + self.assertIn("User Registration", title_text) # Check the form invites correctly username = self.browser.find_element_by_id('id_username') @@ -31,7 +31,7 @@ class UserRegistrationTest(LiveServerTestCase): self.assertEqual(password1.get_attribute('placeholder'), 'Password') self.assertEqual(password1.get_attribute('type'), 'password') password2 = self.browser.find_element_by_id('id_password2') - self.assertEqual(password2.get_attribute('placeholder'), 'Password (again)') + self.assertEqual(password2.get_attribute('placeholder'), 'Password confirmation') self.assertEqual(password2.get_attribute('type'), 'password') first_name = self.browser.find_element_by_id('id_first_name') self.assertEqual(first_name.get_attribute('placeholder'), 'First name') @@ -41,7 +41,6 @@ class UserRegistrationTest(LiveServerTestCase): self.assertEqual(initials.get_attribute('placeholder'), 'Initials') phone = self.browser.find_element_by_id('id_phone') self.assertEqual(phone.get_attribute('placeholder'), 'Phone') - captcha = self.browser.find_element_by_id('g-recaptcha-response') # Fill the form out incorrectly username.send_keys('TestUsername') @@ -52,7 +51,7 @@ class UserRegistrationTest(LiveServerTestCase): last_name.send_keys('Smith') initials.send_keys('JS') phone.send_keys('0123456789') - captcha.send_keys('PASSED') + self.browser.execute_script("return jQuery('#g-recaptcha-response').val('PASSED')") # Submit incorrect form submit = self.browser.find_element_by_xpath("//input[@type='submit']") @@ -60,7 +59,6 @@ class UserRegistrationTest(LiveServerTestCase): # Restablish error fields password1 = self.browser.find_element_by_id('id_password1') password2 = self.browser.find_element_by_id('id_password2') - captcha = self.browser.find_element_by_id('g-recaptcha-response') # Read what the error is alert = self.browser.find_element_by_css_selector('div.alert-danger').text @@ -73,7 +71,7 @@ class UserRegistrationTest(LiveServerTestCase): # Correct error password1.send_keys('correcthorsebatterystaple') password2.send_keys('correcthorsebatterystaple') - captcha.send_keys('PASSED') + self.browser.execute_script("return jQuery('#g-recaptcha-response').val('PASSED')") # Submit again password2.send_keys(Keys.ENTER) @@ -86,7 +84,7 @@ class UserRegistrationTest(LiveServerTestCase): # Check Email self.assertEqual(len(mail.outbox), 1) email = mail.outbox[0] - self.assertIn(email.subject, 'TestUsername activation required') + self.assertIn('activation required', email.subject) urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', email.message) self.assertEqual(len(urls), 2) @@ -106,12 +104,11 @@ class UserRegistrationTest(LiveServerTestCase): password = self.browser.find_element_by_id('id_password') self.assertEqual(password.get_attribute('placeholder'), 'Password') self.assertEqual(password.get_attribute('type'), 'password') - captcha = self.browser.find_element_by_id('g-recaptcha-response') username.send_keys('TestUsername') password.send_keys('correcthorsebatterystaple') password.send_keys(Keys.ENTER) - captcha.send_keys('PASSED') + self.browser.execute_script("return jQuery('#g-recaptcha-response').val('PASSED')") # Check we are logged in udd = self.browser.find_element_by_id('userdropdown')