mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-29 03:12:15 +00:00
Manually undo 28f5158 and move the session wide implicitly_wait to setUp methods.
This commit is contained in:
@@ -19,6 +19,7 @@ class UserRegistrationTest(LiveServerTestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.browser = webdriver.Firefox()
|
self.browser = webdriver.Firefox()
|
||||||
|
self.browser.implicitly_wait(3) # Set implicit wait session wide
|
||||||
os.environ['RECAPTCHA_TESTING'] = 'True'
|
os.environ['RECAPTCHA_TESTING'] = 'True'
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@@ -28,7 +29,6 @@ class UserRegistrationTest(LiveServerTestCase):
|
|||||||
def test_registration(self):
|
def test_registration(self):
|
||||||
# Navigate to the registration page
|
# Navigate to the registration page
|
||||||
self.browser.get(self.live_server_url + '/user/register/')
|
self.browser.get(self.live_server_url + '/user/register/')
|
||||||
# self.browser.implicitly_wait(3)
|
|
||||||
title_text = self.browser.find_element_by_tag_name('h3').text
|
title_text = self.browser.find_element_by_tag_name('h3').text
|
||||||
self.assertIn("User Registration", title_text)
|
self.assertIn("User Registration", title_text)
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ class UserRegistrationTest(LiveServerTestCase):
|
|||||||
# Submit incorrect form
|
# Submit incorrect form
|
||||||
submit = self.browser.find_element_by_xpath("//input[@type='submit']")
|
submit = self.browser.find_element_by_xpath("//input[@type='submit']")
|
||||||
submit.click()
|
submit.click()
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
# Restablish error fields
|
# Restablish error fields
|
||||||
password1 = self.browser.find_element_by_id('id_password1')
|
password1 = self.browser.find_element_by_id('id_password1')
|
||||||
password2 = self.browser.find_element_by_id('id_password2')
|
password2 = self.browser.find_element_by_id('id_password2')
|
||||||
@@ -93,7 +93,6 @@ class UserRegistrationTest(LiveServerTestCase):
|
|||||||
|
|
||||||
# Submit again
|
# Submit again
|
||||||
password2.send_keys(Keys.ENTER)
|
password2.send_keys(Keys.ENTER)
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
# Check we have a success message
|
# Check we have a success message
|
||||||
alert = self.browser.find_element_by_css_selector(
|
alert = self.browser.find_element_by_css_selector(
|
||||||
@@ -131,7 +130,6 @@ class UserRegistrationTest(LiveServerTestCase):
|
|||||||
self.browser.execute_script(
|
self.browser.execute_script(
|
||||||
"return jQuery('#g-recaptcha-response').val('PASSED')")
|
"return jQuery('#g-recaptcha-response').val('PASSED')")
|
||||||
password.send_keys(Keys.ENTER)
|
password.send_keys(Keys.ENTER)
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
# Check we are logged in
|
# Check we are logged in
|
||||||
udd = self.browser.find_element_by_class_name('navbar').text
|
udd = self.browser.find_element_by_class_name('navbar').text
|
||||||
@@ -160,6 +158,7 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05',rate=0.20,comment='test1')
|
self.vatrate = models.VatRate.objects.create(start_at='2014-03-05',rate=0.20,comment='test1')
|
||||||
|
|
||||||
self.browser = webdriver.Firefox()
|
self.browser = webdriver.Firefox()
|
||||||
|
self.browser.implicitly_wait(3) # Set implicit wait session wide
|
||||||
os.environ['RECAPTCHA_TESTING'] = 'True'
|
os.environ['RECAPTCHA_TESTING'] = 'True'
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@@ -171,7 +170,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.live_server_url + '/user/login/', self.browser.current_url)
|
self.live_server_url + '/user/login/', self.browser.current_url)
|
||||||
if n:
|
if n:
|
||||||
self.assertIn('?next=%s' % n, self.browser.current_url)
|
self.assertIn('?next=%s' % n, self.browser.current_url)
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
username = self.browser.find_element_by_id('id_username')
|
username = self.browser.find_element_by_id('id_username')
|
||||||
password = self.browser.find_element_by_id('id_password')
|
password = self.browser.find_element_by_id('id_password')
|
||||||
submit = self.browser.find_element_by_css_selector(
|
submit = self.browser.find_element_by_css_selector(
|
||||||
@@ -182,7 +180,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.browser.execute_script(
|
self.browser.execute_script(
|
||||||
"return jQuery('#g-recaptcha-response').val('PASSED')")
|
"return jQuery('#g-recaptcha-response').val('PASSED')")
|
||||||
submit.click()
|
submit.click()
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
self.assertEqual(self.live_server_url + n, self.browser.current_url)
|
self.assertEqual(self.live_server_url + n, self.browser.current_url)
|
||||||
|
|
||||||
@@ -206,7 +203,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.authenticate('/event/create/')
|
self.authenticate('/event/create/')
|
||||||
|
|
||||||
wait = WebDriverWait(self.browser, 10) #setup WebDriverWait to use later (to wait for animations)
|
wait = WebDriverWait(self.browser, 10) #setup WebDriverWait to use later (to wait for animations)
|
||||||
self.browser.implicitly_wait(3) #Set session-long wait (only works for non-existant DOM objects)
|
|
||||||
|
|
||||||
wait.until(animation_is_finished())
|
wait.until(animation_is_finished())
|
||||||
|
|
||||||
@@ -375,7 +371,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
e = modal.find_element_by_id("item_cost")
|
e = modal.find_element_by_id("item_cost")
|
||||||
e.send_keys("23.95")
|
e.send_keys("23.95")
|
||||||
e.send_keys(Keys.ENTER) # enter submit
|
e.send_keys(Keys.ENTER) # enter submit
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
# Confirm item has been saved to json field
|
# Confirm item has been saved to json field
|
||||||
objectitems = self.browser.execute_script("return objectitems;")
|
objectitems = self.browser.execute_script("return objectitems;")
|
||||||
@@ -425,7 +420,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
e = self.browser.find_element_by_id('id_name')
|
e = self.browser.find_element_by_id('id_name')
|
||||||
e.send_keys('Test Event Name')
|
e.send_keys('Test Event Name')
|
||||||
e.send_keys(Keys.ENTER)
|
e.send_keys(Keys.ENTER)
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
# See redirected to success page
|
# See redirected to success page
|
||||||
event = models.Event.objects.get(name='Test Event Name')
|
event = models.Event.objects.get(name='Test Event Name')
|
||||||
@@ -454,7 +448,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.authenticate('/event/' + str(testEvent.pk) + '/duplicate/')
|
self.authenticate('/event/' + str(testEvent.pk) + '/duplicate/')
|
||||||
|
|
||||||
wait = WebDriverWait(self.browser, 10) #setup WebDriverWait to use later (to wait for animations)
|
wait = WebDriverWait(self.browser, 10) #setup WebDriverWait to use later (to wait for animations)
|
||||||
self.browser.implicitly_wait(3) #Set session-long wait (only works for non-existant DOM objects)
|
|
||||||
|
|
||||||
save = self.browser.find_element_by_xpath(
|
save = self.browser.find_element_by_xpath(
|
||||||
'(//button[@type="submit"])[3]')
|
'(//button[@type="submit"])[3]')
|
||||||
@@ -479,11 +472,9 @@ class EventTest(LiveServerTestCase):
|
|||||||
e = modal.find_element_by_id("item_cost")
|
e = modal.find_element_by_id("item_cost")
|
||||||
e.send_keys("23.95")
|
e.send_keys("23.95")
|
||||||
e.send_keys(Keys.ENTER) # enter submit
|
e.send_keys(Keys.ENTER) # enter submit
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
# Attempt to save
|
# Attempt to save
|
||||||
save.click()
|
save.click()
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
self.assertNotIn("N0000%d"%testEvent.pk, self.browser.find_element_by_xpath('//h1').text)
|
self.assertNotIn("N0000%d"%testEvent.pk, self.browser.find_element_by_xpath('//h1').text)
|
||||||
|
|
||||||
@@ -516,7 +507,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
self.authenticate('/event/create/')
|
self.authenticate('/event/create/')
|
||||||
|
|
||||||
wait = WebDriverWait(self.browser, 10) #setup WebDriverWait to use later (to wait for animations)
|
wait = WebDriverWait(self.browser, 10) #setup WebDriverWait to use later (to wait for animations)
|
||||||
self.browser.implicitly_wait(3) #Set session-long wait (only works for non-existant DOM objects)
|
|
||||||
|
|
||||||
wait.until(animation_is_finished())
|
wait.until(animation_is_finished())
|
||||||
|
|
||||||
@@ -539,7 +529,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
|
|
||||||
# Attempt to save - should fail
|
# Attempt to save - should fail
|
||||||
save.click()
|
save.click()
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
||||||
self.assertTrue(error.is_displayed())
|
self.assertTrue(error.is_displayed())
|
||||||
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
||||||
@@ -562,7 +551,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
|
|
||||||
# Attempt to save - should fail
|
# Attempt to save - should fail
|
||||||
save.click()
|
save.click()
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
||||||
self.assertTrue(error.is_displayed())
|
self.assertTrue(error.is_displayed())
|
||||||
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
||||||
@@ -600,7 +588,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
|
|
||||||
# Attempt to save - should fail
|
# Attempt to save - should fail
|
||||||
save.click()
|
save.click()
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
error = self.browser.find_element_by_xpath('//div[contains(@class, "alert-danger")]')
|
||||||
self.assertTrue(error.is_displayed())
|
self.assertTrue(error.is_displayed())
|
||||||
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
self.assertIn("can't finish before it has started", error.find_element_by_xpath('//dd[1]/ul/li').text)
|
||||||
@@ -621,7 +608,6 @@ class EventTest(LiveServerTestCase):
|
|||||||
|
|
||||||
# Attempt to save - should succeed
|
# Attempt to save - should succeed
|
||||||
save.click()
|
save.click()
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
# See redirected to success page
|
# See redirected to success page
|
||||||
event = models.Event.objects.get(name='Test Event Name')
|
event = models.Event.objects.get(name='Test Event Name')
|
||||||
@@ -716,6 +702,7 @@ class IcalTest(LiveServerTestCase):
|
|||||||
models.Event.objects.create(name="TE E18", start_date=date.today(), is_rig=False, status=models.Event.CANCELLED, description="non rig today cancelled")
|
models.Event.objects.create(name="TE E18", start_date=date.today(), is_rig=False, status=models.Event.CANCELLED, description="non rig today cancelled")
|
||||||
|
|
||||||
self.browser = webdriver.Firefox()
|
self.browser = webdriver.Firefox()
|
||||||
|
self.browser.implicitly_wait(3) # Set implicit wait session wide
|
||||||
os.environ['RECAPTCHA_TESTING'] = 'True'
|
os.environ['RECAPTCHA_TESTING'] = 'True'
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
@@ -737,7 +724,6 @@ class IcalTest(LiveServerTestCase):
|
|||||||
self.browser.execute_script(
|
self.browser.execute_script(
|
||||||
"return jQuery('#g-recaptcha-response').val('PASSED')")
|
"return jQuery('#g-recaptcha-response').val('PASSED')")
|
||||||
submit.click()
|
submit.click()
|
||||||
self.browser.implicitly_wait(3)
|
|
||||||
|
|
||||||
self.assertEqual(self.live_server_url + n, self.browser.current_url)
|
self.assertEqual(self.live_server_url + n, self.browser.current_url)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user