diff --git a/django/conf/global_settings.py b/django/conf/global_settings.py
index 6b09be2..ed72df9 100644
--- a/django/conf/global_settings.py
+++ b/django/conf/global_settings.py
@@ -560,6 +560,15 @@ DEFAULT_EXCEPTION_REPORTER_FILTER = 'django.views.debug.SafeExceptionReporterFil
 # The name of the class to use to run the test suite
 TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner'
 
+# For the live test server (e.g. used for running Selenium tests)
+LIVE_TEST_SERVER_HOST = 'localhost'
+LIVE_TEST_SERVER_PORT = 8080
+
+# For Selenium
+SELENIUM_SERVER_HOST = 'localhost'
+SELENIUM_SERVER_PORT = 4444
+SELENIUM_BROWSER = '*firefox'
+
 ############
 # FIXTURES #
 ############
diff --git a/django/test/__init__.py b/django/test/__init__.py
index a3a03e3..b246821 100644
--- a/django/test/__init__.py
+++ b/django/test/__init__.py
@@ -4,5 +4,6 @@ Django Unit Test and Doctest framework.
 
 from django.test.client import Client, RequestFactory
 from django.test.testcases import (TestCase, TransactionTestCase,
-        SimpleTestCase, skipIfDBFeature, skipUnlessDBFeature)
+    SimpleTestCase, LiveServerTestCase, SeleniumTestCase, skipIfDBFeature,
+    skipUnlessDBFeature)
 from django.test.utils import Approximate
diff --git a/django/test/testcases.py b/django/test/testcases.py
index ee22ac2..aebb30a 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1,16 +1,24 @@
 from __future__ import with_statement
 
+import httplib
 import re
 import sys
 from functools import wraps
 from urlparse import urlsplit, urlunsplit
 from xml.dom.minidom import parseString, Node
+import select
+import socket
+import threading
 
 from django.conf import settings
+from django.contrib.staticfiles.handlers import StaticFilesHandler
 from django.core import mail
 from django.core.exceptions import ValidationError
+from django.core.handlers.wsgi import WSGIHandler
 from django.core.management import call_command
 from django.core.signals import request_started
+from django.core.servers.basehttp import (WSGIRequestHandler, WSGIServer,
+    WSGIServerException)
 from django.core.urlresolvers import clear_url_caches
 from django.core.validators import EMPTY_VALUES
 from django.db import (transaction, connection, connections, DEFAULT_DB_ALIAS,
@@ -23,6 +31,7 @@ from django.test.utils import (get_warnings_state, restore_warnings_state,
     override_settings)
 from django.utils import simplejson, unittest as ut2
 from django.utils.encoding import smart_str
+from django.utils.unittest import skipUnless
 
 __all__ = ('DocTestRunner', 'OutputChecker', 'TestCase', 'TransactionTestCase',
            'SimpleTestCase', 'skipIfDBFeature', 'skipUnlessDBFeature')
@@ -732,3 +741,200 @@ def skipUnlessDBFeature(feature):
     """
     return _deferredSkip(lambda: not getattr(connection.features, feature),
                          "Database doesn't support feature %s" % feature)
+
+class QuietWSGIRequestHandler(WSGIRequestHandler):
+    """
+    Just a regular WSGIRequestHandler except it doesn't log to the standard
+    output any of the requests received, so as to not clutter the output for
+    the tests' results.
+    """
+    def log_message(*args):
+        pass
+
+class StoppableWSGIServer(WSGIServer):
+    """
+    The code in this class is borrowed from the `SocketServer.BaseServer` class
+    in Python 2.6. The important functionality here is that the server is non-
+    blocking and that it can be shut down at any moment. This is made possible
+    by the server regularly polling the socket and checking if it has been
+    asked to stop.
+    Note for the future: Once Django stops supporting Python 2.5, this class
+    can be removed as `WSGIServer` will have this ability to shutdown on
+    demand.
+    """
+
+    def __init__(self, *args, **kwargs):
+        super(StoppableWSGIServer, self).__init__(*args, **kwargs)
+        self.__is_shut_down = threading.Event()
+        self.__serving = False
+
+    def serve_forever(self, poll_interval=0.5):
+        """Handle one request at a time until shutdown.
+
+        Polls for shutdown every poll_interval seconds.
+        """
+        self.__serving = True
+        self.__is_shut_down.clear()
+        while self.__serving:
+            r, w, e = select.select([self], [], [], poll_interval)
+            if r:
+                self._handle_request_noblock()
+        self.__is_shut_down.set()
+
+    def shutdown(self):
+        """Stops the serve_forever loop.
+
+        Blocks until the loop has finished. This must be called while
+        serve_forever() is running in another thread, or it will
+        deadlock.
+        """
+        self.__serving = False
+        self.__is_shut_down.wait()
+
+    def handle_request(self):
+        """Handle one request, possibly blocking.
+        """
+        fd_sets = select.select([self], [], [], None)
+        if not fd_sets[0]:
+            return
+        self._handle_request_noblock()
+
+    def _handle_request_noblock(self):
+        """Handle one request, without blocking.
+
+        I assume that select.select has returned that the socket is
+        readable before this function was called, so there should be
+        no risk of blocking in get_request().
+        """
+        try:
+            request, client_address = self.get_request()
+        except socket.error:
+            return
+        if self.verify_request(request, client_address):
+            try:
+                self.process_request(request, client_address)
+            except Exception:
+                self.handle_error(request, client_address)
+                self.close_request(request)
+
+class LiveServerThread(threading.Thread):
+    """
+    Thread for running a live http server while the tests are running.
+    """
+
+    def __init__(self, address, port, fixtures):
+        self.address = address
+        self.port = port
+        self.fixtures = fixtures
+        self.is_ready = threading.Event()
+        self.error = None
+        super(LiveServerThread, self).__init__()
+
+    def run(self):
+        """
+        Sets up live server and database and loops over handling http requests.
+        """
+        try:
+            # Instantiate and start the server
+            self.httpd = StoppableWSGIServer(
+                (self.address, self.port), QuietWSGIRequestHandler)
+            handler = StaticFilesHandler(WSGIHandler())
+            self.httpd.set_app(handler)
+
+            # If the database is in memory we must reload the data in this new
+            # thread.
+            if (settings.DATABASES['default']['ENGINE'] == 'django.db.backends.sqlite3' or
+                settings.DATABASES['default']['TEST_NAME']):
+                connection.creation.create_test_db(0)
+                # Import the fixtures into the test database
+                if hasattr(self, 'fixtures'):
+                    call_command('loaddata', *self.fixtures,
+                        **{'verbosity': 0})
+            self.is_ready.set()
+            self.httpd.serve_forever()
+        except WSGIServerException, e:
+            self.error = e
+            self.is_ready.set()
+
+    def join(self, timeout=None):
+        self.httpd.shutdown()
+        self.httpd.server_close()
+        super(LiveServerThread, self).join(timeout)
+
+class LiveServerTestCase(TestCase):
+    """
+    Does basically the same as TestCase but also launches a live http server in
+    a separate thread so that the tests may use another testing framework, such
+    as Selenium for example, instead of the built-in dummy client.
+    """
+
+    fixtures = []
+
+    def setUp(self):
+        # Launch the Django live server's thread
+        self.server_thread = LiveServerThread(
+            settings.LIVE_TEST_SERVER_HOST,
+            int(settings.LIVE_TEST_SERVER_PORT),
+            fixtures=self.fixtures)
+        self.server_thread.start()
+        super(LiveServerTestCase, self).setUp()
+
+    def tearDown(self):
+        # Terminate the Django server's thread
+        self.server_thread.join()
+        super(LiveServerTestCase, self).tearDown()
+
+try:
+    # Check if the 'selenium' package is installed
+    from selenium import selenium
+    selenium_installed = True
+except ImportError:
+    selenium_installed = False
+
+# Check if the Selenium server is running
+try:
+    conn = httplib.HTTPConnection(settings.SELENIUM_SERVER_HOST,
+        settings.SELENIUM_SERVER_PORT)
+    try:
+        conn.request("GET", "/selenium-server/driver/", '', {})
+    finally:
+        conn.close()
+    selenium_server_running = True
+except socket.error:
+    selenium_server_running = False
+
+class SeleniumTestCase(LiveServerTestCase):
+    """
+    Does basically the same as TestServerTestCase but also connects to the
+    Selenium server. The selenium client is then available with
+    'self.selenium'. The requirements are to have the 'selenium' installed in
+    the python path and to have the Selenium server running. If those
+    requirements are not filled then the tests will be skipped.
+    """
+
+    def setUp(self):
+        super(SeleniumTestCase, self).setUp()
+        # Launch the Selenium server
+        selenium_browser_url = 'http://%s:%s' % (
+            settings.LIVE_TEST_SERVER_HOST, settings.LIVE_TEST_SERVER_PORT)
+        self.selenium = selenium(
+            settings.SELENIUM_SERVER_HOST,
+            int(settings.SELENIUM_SERVER_PORT),
+            settings.SELENIUM_BROWSER,
+            selenium_browser_url)
+        self.selenium.start()
+        # Wait for the Django server to be ready
+        self.server_thread.is_ready.wait()
+        if self.server_thread.error:
+            raise self.server_thread.error
+
+    def tearDown(self):
+        super(SeleniumTestCase, self).tearDown()
+        self.selenium.stop()
+
+SeleniumTestCase = skipUnless(selenium_installed,
+    'The \'selenium\' package isn\'t installed')(SeleniumTestCase)
+SeleniumTestCase = skipUnless(selenium_server_running,
+    'Can\'t connect to the Selenium server using address %s and port %s' % (
+    settings.SELENIUM_SERVER_HOST, settings.SELENIUM_SERVER_PORT)
+)(SeleniumTestCase)
\ No newline at end of file
diff --git a/docs/internals/contributing/writing-code/unit-tests.txt b/docs/internals/contributing/writing-code/unit-tests.txt
index 5ec09fe..cec408c 100644
--- a/docs/internals/contributing/writing-code/unit-tests.txt
+++ b/docs/internals/contributing/writing-code/unit-tests.txt
@@ -122,6 +122,31 @@ Going beyond that, you can specify an individual test method like this:
 
     ./runtests.py --settings=path.to.settings i18n.TranslationTests.test_lazy_objects
 
+Running the Selenium tests
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Some admin tests require Selenium to work via a real Web browser. To allow
+those tests to run and not be skipped, you must install the selenium_ package
+into your Python path and download the `Selenium server (>2.12.0)`_. The
+Selenium server must then be started with the following command:
+
+.. code-block:: bash
+
+    java -jar selenium-server-standalone-2.12.0.jar
+
+If you're using linux, you may also run the tests in headless mode (i.e. with a
+virtual display) using with the following command instead:
+
+.. code-block:: bash
+
+    Xvfb :99 -ac & && DISPLAY=:99 java -jar selenium-server-standalone-2.12.0.jar
+
+Then, run the tests normally, for example:
+
+.. code-block:: bash
+
+    ./runtests.py --settings=test_sqlite admin_inlines
+
 Running all the tests
 ~~~~~~~~~~~~~~~~~~~~~
 
@@ -135,6 +160,7 @@ dependencies:
 *  setuptools_
 *  memcached_, plus a :ref:`supported Python binding <memcached>`
 *  gettext_ (:ref:`gettext_on_windows`)
+*  selenium_ plus the `Selenium server (>2.12.0)`_
 
 If you want to test the memcached cache backend, you'll also need to define
 a :setting:`CACHES` setting that points at your memcached instance.
@@ -149,6 +175,8 @@ associated tests will be skipped.
 .. _setuptools: http://pypi.python.org/pypi/setuptools/
 .. _memcached: http://www.danga.com/memcached/
 .. _gettext: http://www.gnu.org/software/gettext/manual/gettext.html
+.. _selenium: http://pypi.python.org/pypi/selenium
+.. _Selenium server (>2.12.0): http://seleniumhq.org/download/
 
 .. _contrib-apps:
 
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index 20366e3..16caf48 100644
--- a/docs/ref/settings.txt
+++ b/docs/ref/settings.txt
@@ -195,6 +195,30 @@ all cache keys used by the Django server.
 
 See the :ref:`cache documentation <cache_key_prefixing>` for more information.
 
+.. setting:: LIVE_TEST_SERVER_HOST
+
+LIVE_TEST_SERVER_HOST
+~~~~~~~~~~~~~~~~~~~~~
+
+Default: ``'localhost'``
+
+Controls the host address at which the live test server gets started when using
+a :class:`~django.test.LiveServerTestCase`.
+
+See also: :setting:`LIVE_TEST_SERVER_PORT`
+
+.. setting:: LIVE_TEST_SERVER_PORT
+
+LIVE_TEST_SERVER_PORT
+~~~~~~~~~~~~~~~~~~~~~
+
+Default: ``8080``
+
+Controls the port at which the live test server gets started when using
+a :class:`~django.test.LiveServerTestCase`.
+
+See also: :setting:`LIVE_TEST_SERVER_HOST`
+
 .. setting:: CACHES-LOCATION
 
 LOCATION
@@ -496,6 +520,53 @@ Default: ``''`` (Empty string)
 The port to use when connecting to the database. An empty string means the
 default port. Not used with SQLite.
 
+.. setting:: SELENIUM_SERVER_HOST
+
+SELENIUM_SERVER_HOST
+~~~~~~~~~~~~~~~~~~~~
+
+Default: ``localhost``
+
+Host address where the Selenium server can be accessed.
+
+.. setting:: SELENIUM_SERVER_PORT
+
+SELENIUM_SERVER_PORT
+~~~~~~~~~~~~~~~~~~~~
+
+Default: ``4444``
+
+Port where the Selenium server can be accessed.
+
+.. setting:: SELENIUM_BROWSER
+
+SELENIUM_BROWSER
+~~~~~~~~~~~~~~~~
+
+Default: ``'*firefox'``
+
+Browser to be used when running Selenium tests. Note that the prefixing star
+('``*``') is required. Possible values include:
+
+*  ``'*firefox'``
+*  ``'*googlechrome'``
+*  ``'*safari'``
+*  ``'*mock'``
+*  ``'*firefoxproxy'``
+*  ``'*pifirefox'``
+*  ``'*chrome'``
+*  ``'*iexploreproxy'``
+*  ``'*iexplore'``
+*  ``'*safariproxy'``
+*  ``'*konqueror'``
+*  ``'*firefox2'``
+*  ``'*firefox3'``
+*  ``'*firefoxchrome'``
+*  ``'*piiexplore'``
+*  ``'*opera'``
+*  ``'*iehta'``
+*  ``'*custom'``
+
 .. setting:: USER
 
 USER
diff --git a/docs/topics/testing.txt b/docs/topics/testing.txt
index dc5bf7e..9b9ed1c 100644
--- a/docs/topics/testing.txt
+++ b/docs/topics/testing.txt
@@ -580,21 +580,21 @@ Some of the things you can do with the test client are:
 * Test that a given request is rendered by a given Django template, with
   a template context that contains certain values.
 
-Note that the test client is not intended to be a replacement for Twill_,
+Note that the test client is not intended to be a replacement for Windmill_,
 Selenium_, or other "in-browser" frameworks. Django's test client has
 a different focus. In short:
 
 * Use Django's test client to establish that the correct view is being
   called and that the view is collecting the correct context data.
 
-* Use in-browser frameworks such as Twill and Selenium to test *rendered*
-  HTML and the *behavior* of Web pages, namely JavaScript functionality.
+* Use in-browser frameworks such as Windmill_ and Selenium_ to test *rendered*
+  HTML and the *behavior* of Web pages, namely JavaScript functionality. Django
+  also provides special support for those frameworks; see the sections on
+  :class:`~django.test.testcases.LiveServerTestCase` and
+  :class:`~django.test.testcases.SeleniumTestCase`.
 
 A comprehensive test suite should use a combination of both test types.
 
-.. _Twill: http://twill.idyll.org/
-.. _Selenium: http://seleniumhq.org/
-
 Overview and a quick example
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -1828,11 +1828,114 @@ set up, execute and tear down the test suite.
     those options will be added to the list of command-line options that
     the :djadmin:`test` command can use.
 
+Live test server
+----------------
+
+.. currentmodule:: django.test
+
+.. versionadded::1.4
+
+.. class:: LiveServerTestCase()
+
+``LiveServerTestCase`` does basically the same as
+:class:`~django.test.TestCase` with one extra thing: it launches a live Django
+server in the background on setup, and shuts it down on teardown. This allows
+to use other automated test clients than the
+:ref:`Django dummy client <test-client>` such as, for example, the Selenium_ or
+Windmill_ clients.
+
+You may control which host and port the live server will run at with
+respectively the :setting:`LIVE_TEST_SERVER_HOST` and
+:setting:`LIVE_TEST_SERVER_PORT` settings.
+
+Fixtures defined with the :attr:`~TestCase.fixtures` class attribute will get
+loaded at the beginning of each test if you require some initial data to be
+present.
+
+See the section on :class:`SeleniumTestCase` for a concrete example of how
+``LiveServerTestCase`` can be used.
+
+Selenium tests
+--------------
+
+.. versionadded::1.4
+
+.. class:: SeleniumTestCase()
+
+Django provides out-of-the box support for Selenium_ tests with the
+``SeleniumTestCase`` class. Django itself uses it in its own test suite for
+some ``contrib.admin`` tests.
+
+``SeleniumTestCase`` inherits from :class:`LiveServerTestCase`, which means
+that a live server is available for the duration of each test. That live server
+can then be accessed by the Selenium client to execute a series of functional
+tests inside a browser, simulating a real user's actions.
+
+To get started with Selenium tests, your environment needs to satisfy a number
+of requirements:
+
+*  You must install the `selenium package`_ into your Python path:
+
+   .. code-block:: bash
+
+       pip install selenium
+
+*  You must download the `Selenium server (>2.12.0)`_, and then start it with
+   the following command:
+
+   .. code-block:: bash
+
+       java -jar selenium-server-standalone-2.12.0.jar
+
+   If you'd like to run the selenium server at a different port than the
+   standard one (i.e. 4444) you may do so as follows:
+
+   .. code-block:: bash
+
+       java -jar selenium-server-standalone-2.12.0.jar -port 1234
+
+*  If the selenium server isn't running at the standard host address or port,
+   you need to provide the exact details using respectively the
+   :setting:`SELENIUM_SERVER_HOST` and :setting:`SELENIUM_SERVER_PORT`
+   settings.
+
+If those requirements are not satisfied, then the tests will be skipped.
+
+By the default, the tests are run in Firefox_. If you do not have Firefox
+installed or simply wish to run the tests in another browser, you may do so by
+changing the :setting:`SELENIUM_BROWSER` setting.
+
+Once your environment is set up, you may start writing your Selenium tests.
+Here's an example of how to control the Selenium client (accessible via
+``self.selenium``):
+
+.. code-block:: python
+
+    from django.test import SeleniumTestCase
+
+    class MySeleniumTests(SeleniumTestCase):
+
+        fixtures = ['user-data.json']
+
+        def test_login(self):
+            self.selenium.open('/login/')
+            self.selenium.type('username', username)
+            self.selenium.type('password', password)
+            self.selenium.click("//input[@value='Log in']")
+
+This is just a tiny fraction of what the Selenium client can do. Check out the
+`full reference`_ for more details.
+
+.. _Windmill: http://www.getwindmill.com/
+.. _Selenium: http://seleniumhq.org/
+.. _selenium package: http://pypi.python.org/pypi/selenium
+.. _Selenium server (>2.12.0): http://seleniumhq.org/download/
+.. _full reference: http://selenium.googlecode.com/svn/trunk/docs/api/py/selenium/selenium.selenium.html
+.. _Firefox: http://www.mozilla.com/firefox/
 
 Attributes
 ~~~~~~~~~~
 
-
 .. attribute:: DjangoTestSuiteRunner.option_list
 
     .. versionadded:: 1.4
diff --git a/tests/regressiontests/admin_inlines/tests.py b/tests/regressiontests/admin_inlines/tests.py
index c2e3bbc..942ece6 100644
--- a/tests/regressiontests/admin_inlines/tests.py
+++ b/tests/regressiontests/admin_inlines/tests.py
@@ -7,6 +7,7 @@ from django.test import TestCase
 
 # local test models
 from .admin import InnerInline
+from django.test.testcases import SeleniumTestCase
 from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person,
     OutfitItem, Fashionista, Teacher, Parent, Child, Author, Book)
 
@@ -380,3 +381,99 @@ class TestInlinePermissions(TestCase):
         self.assertContains(response, 'value="4" id="id_inner2_set-TOTAL_FORMS"')
         self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
         self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
+
+
+class SeleniumTests(SeleniumTestCase):
+    fixtures = ['admin-views-users.xml']
+    urls = "regressiontests.admin_inlines.urls"
+
+    def admin_login(self, username, password):
+        """
+        Helper function to log into the admin.
+        """
+        self.selenium.open('/admin/')
+        self.selenium.type('username', username)
+        self.selenium.type('password', password)
+        self.selenium.click("//input[@value='Log in']")
+        self.selenium.wait_for_page_to_load(3000)
+
+    def test_add_inlines(self):
+        """
+        Ensure that the "Add another XXX" link correctly adds items to the
+        inline form.
+        """
+        self.admin_login(username='super', password='secret')
+        self.selenium.open('/admin/admin_inlines/titlecollection/add/')
+
+        # Check that there's only one inline to start with and that it has the
+        # correct ID.
+        self.failUnlessEqual(self.selenium.get_css_count(
+            'css=#title_set-group table tr.dynamic-title_set'), 1)
+        self.failUnless(self.selenium.get_attribute(
+            'css=.dynamic-title_set:nth-of-type(1)@id'), 'title_set-0')
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-0 input[name=title_set-0-title1]'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-0 input[name=title_set-0-title2]'))
+
+        # Add an inline
+        self.selenium.click("link=Add another Title")
+
+        # Check that the inline has been added, that it has the right id, and
+        # that it contains the right fields.
+        self.failUnlessEqual(self.selenium.get_css_count(
+            'css=#title_set-group table tr.dynamic-title_set'), 2)
+        self.failUnless(self.selenium.get_attribute(
+            'css=.dynamic-title_set:nth-of-type(2)@id'), 'title_set-1')
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-1 input[name=title_set-1-title1]'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-1 input[name=title_set-1-title2]'))
+
+        # Let's add another one to be sure
+        self.selenium.click("link=Add another Title")
+        self.failUnlessEqual(self.selenium.get_css_count(
+            'css=#title_set-group table tr.dynamic-title_set'), 3)
+        self.failUnless(self.selenium.get_attribute(
+            'css=.dynamic-title_set:nth-of-type(3)@id'), 'title_set-2')
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-2 input[name=title_set-2-title1]'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-2 input[name=title_set-2-title2]'))
+
+    def test_delete_inlines(self):
+        self.admin_login(username='super', password='secret')
+        self.selenium.open('/admin/admin_inlines/titlecollection/add/')
+
+        # Add a few inlines
+        self.selenium.click("link=Add another Title")
+        self.selenium.click("link=Add another Title")
+        self.selenium.click("link=Add another Title")
+        self.selenium.click("link=Add another Title")
+        self.failUnlessEqual(self.selenium.get_css_count(
+            'css=#title_set-group table tr.dynamic-title_set'), 5)
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-0'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-1'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-2'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-3'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-4'))
+
+        # Click on a few delete buttons
+        self.selenium.click(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-1 td.delete a')
+        self.selenium.click(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-2 td.delete a')
+        # Verify that they're gone and that the IDs have been re-sequenced
+        self.failUnlessEqual(self.selenium.get_css_count(
+            'css=#title_set-group table tr.dynamic-title_set'), 3)
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-0'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-1'))
+        self.failUnless(self.selenium.is_element_present(
+            'css=form#titlecollection_form tr.dynamic-title_set#title_set-2'))
\ No newline at end of file
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index 08a1a59..c0704d5 100644
--- a/tests/regressiontests/admin_widgets/tests.py
+++ b/tests/regressiontests/admin_widgets/tests.py
@@ -11,6 +11,7 @@ from django.core.files.storage import default_storage
 from django.core.files.uploadedfile import SimpleUploadedFile
 from django.db.models import DateField
 from django.test import TestCase as DjangoTestCase
+from django.test.testcases import SeleniumTestCase
 from django.utils import translation
 from django.utils.html import conditional_escape
 from django.utils.unittest import TestCase
@@ -372,3 +373,67 @@ 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 SeleniumTests(SeleniumTestCase):
+    fixtures = ['admin-widgets-users.xml']
+    urls = "regressiontests.admin_widgets.urls"
+
+    def admin_login(self, username, password):
+        """
+        Helper function to log into the admin.
+        """
+        self.selenium.open('/')
+        self.selenium.type('username', username)
+        self.selenium.type('password', password)
+        self.selenium.click("//input[@value='Log in']")
+        self.selenium.wait_for_page_to_load(3000)
+
+    def get_css_value(self, selector, attribute):
+        """
+        Helper function that returns the value for the CSS attribute of an
+        DOM element specified by the given selector.
+        """
+        return self.selenium.get_eval(
+            'selenium.browserbot.getCurrentWindow().django'
+            '.jQuery("%s").css("%s")' % (selector, attribute))
+
+    def test_show_hide_date_time_picker_widgets(self):
+        """
+        Ensure that pressing the ESC key closes the date and time picker
+        widgets.
+        Refs #17064.
+        """
+        self.admin_login(username='super', password='secret')
+        # Open a page that has a date and time picker widgets
+        self.selenium.open('/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.click('id=calendarlink0')
+        # Check that the date picker is visible
+        self.assertEqual(
+            self.get_css_value('#calendarbox0', 'display'), 'block')
+        # Press the ESC key
+        self.selenium.key_up('css=html', '27')
+        # 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.click('id=clocklink0')
+        # Check that the time picker is visible
+        self.assertEqual(
+            self.get_css_value('#clockbox0', 'display'), 'block')
+        # Press the ESC key
+        self.selenium.key_up('css=html', '27')
+        # Check that the time picker is hidden again
+        self.assertEqual(
+            self.get_css_value('#clockbox0', 'display'), 'none')
\ No newline at end of file
