def test_webtest(self):
        resp = self.app.get('/',
                            {'redirect': '/message.html?message=submited'})
        resp.mustcontain('It Works!')
        form = resp.forms['myform']
        form.lint()

        self.assertEqual(form['mytext'].value, '')
        resp.mustcontain(no='Form submited')

        with webtest_selenium.selenium(resp) as sresp:
            if sresp:
                sform = sresp.forms['myform']
                sform['mytext'] = 'foo'
                sresp = sform.submit(name='go', timeout=0)
                sresp.mustcontain('Form submited')

        if resp.updated:
            resp.mustcontain('Form submited')
            form = resp.forms['myform']
            self.assertEqual(form['mytext'].value, 'foo')

        resp = form.submit(name='go')
        resp = resp.follow()
        resp.mustcontain('<pre>submited</pre>')
        self.assertRaises(webtest.AppError, resp.follow)

    def test_404(self):
        self.assertRaises(webtest.AppError, self.app.get, '/404')
        self.app.get('/404', status=404)
        self.assertRaises(webtest.AppError, self.app.get, '/404.html')

    def test_500(self):
        self.assertRaises(webtest.AppError, self.app.get, '/500')
        self.app.get('/500', status=500)

    @classmethod
    def teardownClass(cls):
        cls.app.close()

TestStatus = webtest_selenium.selenium(TestStatus)


class TestJQueryUI(unittest.TestCase):

    @classmethod
    def setupClass(cls):
        cls.app = webtest_selenium.SeleniumApp(url='http://jqueryui.com/')

    def setUp(self):
        self.resp = self.app.get('http://jqueryui.com/demos/')

    def test_datepicker(self):
        resp = self.resp.click('Datepicker')
        field = resp.doc.datepicker
        field.fireEvent('focus')