Skip to content

Commit

Permalink
Fixed a timing edge case in the RelatedFieldWidgetSeleniumFirefoxTests.
Browse files Browse the repository at this point in the history
By settings an implicit wait timeout for the find_* methods we can wait
till the javascript code add the new option to the DOM.

See http://ci.djangoproject.com/job/Django/database=mysql_gis,python=python3.3/3174/testReport/junit/admin_widgets.tests/RelatedFieldWidgetSeleniumFirefoxTests/test_foreign_key_using_to_field/

Stacktrace:
Traceback (most recent call last):
  File "/var/lib/jenkins/jobs/Django/workspace/database/mysql_gis/python/python3.3/tests/admin_widgets/tests.py", line 1060, in test_foreign_key_using_to_field
      self.assertEqual(username_value, new_option.get_attribute('value'))
      AssertionError: 'newuser' != 'testser'
      - newuser
      + testser
  • Loading branch information
apollo13 committed Sep 14, 2013
1 parent 2fa0dd7 commit 351a061
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tests/admin_widgets/tests.py
Expand Up @@ -1055,9 +1055,10 @@ def test_foreign_key_using_to_field(self):
save_button_css_selector = '.submit-row > input[type=submit]' save_button_css_selector = '.submit-row > input[type=submit]'
self.selenium.find_element_by_css_selector(save_button_css_selector).click() self.selenium.find_element_by_css_selector(save_button_css_selector).click()
self.selenium.switch_to_window(main_window) self.selenium.switch_to_window(main_window)
user_select = self.selenium.find_element_by_id('id_user') # Wait up to 2 seconds for the new option to show up after clicking save in the popup.
new_option = user_select.find_elements_by_tag_name('option')[-1] self.selenium.implicitly_wait(2)
self.assertEqual(username_value, new_option.get_attribute('value')) self.selenium.find_element_by_css_selector('#id_user option[value=newuser]')
self.selenium.implicitly_wait(0)


# Go ahead and submit the form to make sure it works # Go ahead and submit the form to make sure it works
self.selenium.find_element_by_css_selector(save_button_css_selector).click() self.selenium.find_element_by_css_selector(save_button_css_selector).click()
Expand All @@ -1070,4 +1071,4 @@ class RelatedFieldWidgetSeleniumChromeTests(RelatedFieldWidgetSeleniumFirefoxTes
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'


class RelatedFieldWidgetSeleniumIETests(RelatedFieldWidgetSeleniumFirefoxTests): class RelatedFieldWidgetSeleniumIETests(RelatedFieldWidgetSeleniumFirefoxTests):
webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver' webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'

0 comments on commit 351a061

Please sign in to comment.