Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a timing edge case in the RelatedFieldWidgetSeleniumFirefoxTests.

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...
commit 351a061497b262e2ef994552d04c31b63d801179 1 parent 2fa0dd7
@apollo13 apollo13 authored
Showing with 5 additions and 4 deletions.
  1. +5 −4 tests/admin_widgets/tests.py
View
9 tests/admin_widgets/tests.py
@@ -1055,9 +1055,10 @@ def test_foreign_key_using_to_field(self):
save_button_css_selector = '.submit-row > input[type=submit]'
self.selenium.find_element_by_css_selector(save_button_css_selector).click()
self.selenium.switch_to_window(main_window)
- user_select = self.selenium.find_element_by_id('id_user')
- new_option = user_select.find_elements_by_tag_name('option')[-1]
- self.assertEqual(username_value, new_option.get_attribute('value'))
+ # Wait up to 2 seconds for the new option to show up after clicking save in the popup.
+ self.selenium.implicitly_wait(2)
+ 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
self.selenium.find_element_by_css_selector(save_button_css_selector).click()
@@ -1070,4 +1071,4 @@ class RelatedFieldWidgetSeleniumChromeTests(RelatedFieldWidgetSeleniumFirefoxTes
webdriver_class = 'selenium.webdriver.chrome.webdriver.WebDriver'
class RelatedFieldWidgetSeleniumIETests(RelatedFieldWidgetSeleniumFirefoxTests):
- webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
+ webdriver_class = 'selenium.webdriver.ie.webdriver.WebDriver'
Please sign in to comment.
Something went wrong with that request. Please try again.