diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/tests.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/django/contrib/admin/tests.py b/django/contrib/admin/tests.py index efe601e723..eb04b40d15 100644 --- a/django/contrib/admin/tests.py +++ b/django/contrib/admin/tests.py @@ -73,15 +73,25 @@ class AdminSeleniumWebDriverTestCase(LiveServerTestCase): return self.selenium.execute_script( 'return django.jQuery("%s").css("%s")' % (selector, attribute)) - def select_option(self, selector, value): + def get_select_option(self, selector, value): """ - Helper function to select the <OPTION> that has the value `value` and - that is in the <SELECT> widget identified by the CSS selector `selector`. + Returns the <OPTION> with the value `value` inside the <SELECT> widget + identified by the CSS selector `selector`. """ from selenium.common.exceptions import NoSuchElementException options = self.selenium.find_elements_by_css_selector('%s option' % selector) for option in options: if option.get_attribute('value') == value: - option.click() - return - raise NoSuchElementException('Option "%s" not found in "%s"' % (value, selector))
\ No newline at end of file + return option + raise NoSuchElementException('Option "%s" not found in "%s"' % (value, selector)) + + def assertSelectOptions(self, selector, values): + """ + Asserts that the <SELECT> widget identified by `selector` has the + options with the given `values`. + """ + options = self.selenium.find_elements_by_css_selector('%s option' % selector) + actual_values = [] + for option in options: + actual_values.append(option.get_attribute('value')) + self.assertEqual(values, actual_values)
\ No newline at end of file |
