mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
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.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user