From 2f02a05ffb45be68b4164b4785ff1826833150a3 Mon Sep 17 00:00:00 2001 From: Julien Phalip Date: Thu, 22 Dec 2011 08:33:58 +0000 Subject: Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for `contrib.admin`. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/admin_widgets/tests.py | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'tests/regressiontests/admin_widgets') diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py index 37fa7bc8ef..e28df32577 100644 --- a/tests/regressiontests/admin_widgets/tests.py +++ b/tests/regressiontests/admin_widgets/tests.py @@ -7,6 +7,7 @@ from django import forms from django.conf import settings from django.contrib import admin from django.contrib.admin import widgets +from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase from django.core.files.storage import default_storage from django.core.files.uploadedfile import SimpleUploadedFile from django.db.models import DateField @@ -407,3 +408,52 @@ class RelatedFieldWidgetWrapperTests(DjangoTestCase): # Used to fail with a name error. w = widgets.RelatedFieldWidgetWrapper(w, rel, widget_admin_site) self.assertFalse(w.can_add_related) + + +class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): + webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' + fixtures = ['admin-widgets-users.xml'] + urls = "regressiontests.admin_widgets.urls" + + def test_show_hide_date_time_picker_widgets(self): + """ + Ensure that pressing the ESC key closes the date and time picker + widgets. + Refs #17064. + """ + from selenium.webdriver.common.keys import Keys + + self.admin_login(username='super', password='secret', login_url='/') + # Open a page that has a date and time picker widgets + self.selenium.get('%s%s' % (self.live_server_url, + '/admin_widgets/member/add/')) + + # First, with the date picker widget --------------------------------- + # Check that the date picker is hidden + self.assertEqual( + self.get_css_value('#calendarbox0', 'display'), 'none') + # Click the calendar icon + self.selenium.find_element_by_id('calendarlink0').click() + # Check that the date picker is visible + self.assertEqual( + self.get_css_value('#calendarbox0', 'display'), 'block') + # Press the ESC key + self.selenium.find_element_by_tag_name('html').send_keys([Keys.ESCAPE]) + # Check that the date picker is hidden again + self.assertEqual( + self.get_css_value('#calendarbox0', 'display'), 'none') + + # Then, with the time picker widget ---------------------------------- + # Check that the time picker is hidden + self.assertEqual( + self.get_css_value('#clockbox0', 'display'), 'none') + # Click the time icon + self.selenium.find_element_by_id('clocklink0').click() + # Check that the time picker is visible + self.assertEqual( + self.get_css_value('#clockbox0', 'display'), 'block') + # Press the ESC key + self.selenium.find_element_by_tag_name('html').send_keys([Keys.ESCAPE]) + # Check that the time picker is hidden again + self.assertEqual( + self.get_css_value('#clockbox0', 'display'), 'none') -- cgit v1.3