diff options
| author | Markus Bertheau <mbertheau@gmail.com> | 2014-01-17 13:29:48 +0100 |
|---|---|---|
| committer | Markus Bertheau <mbertheau@gmail.com> | 2014-01-17 13:29:48 +0100 |
| commit | 9d776cde6df5272cba81d5682611b3f71c797c27 (patch) | |
| tree | 5577c408c076c283047ba84ea43b46529cf7a23f /tests | |
| parent | 973e2be1ccc137f1da7bc1c0b648eea853eb8392 (diff) | |
| download | webtest-9d776cde6df5272cba81d5682611b3f71c797c27.tar.gz | |
Allow selecting submit button by value
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/html/form_inputs.html | 4 | ||||
| -rw-r--r-- | tests/test_forms.py | 21 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/html/form_inputs.html b/tests/html/form_inputs.html index 6333430..4633981 100644 --- a/tests/html/form_inputs.html +++ b/tests/html/form_inputs.html @@ -41,6 +41,10 @@ aaa</textarea> <input type="checkbox" name="checkbox" value="20" checked="checked"> <input type="checkbox" name="checkbox" value="30"> </form> + <form method="POST" id="multiple_buttons_form"> + <button name="action" type="submit" value="deactivate">Deactivate</button> + <button name="action" type="submit" value="activate">Activate</button> + </form> </body> </html> diff --git a/tests/test_forms.py b/tests/test_forms.py index c426001..ab91c39 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -103,6 +103,27 @@ class TestForms(unittest.TestCase): self.assertEqual(form.get('checkbox', index=1).value, None) self.assertEqual(form.get('checkbox', index=2).value, '30') + def test_button_submit(self): + form = self.callFUT(formid='multiple_buttons_form') + display = form.submit('action') + self.assertIn(u("action=deactivate"), display, display) + + def test_button_submit_by_index(self): + form = self.callFUT(formid='multiple_buttons_form') + display = form.submit('action', index=1) + self.assertIn(u("action=activate"), display, display) + + def test_button_submit_by_value(self): + form = self.callFUT(formid='multiple_buttons_form') + display = form.submit('action', value='activate') + self.assertIn(u("action=activate"), display, display) + + def test_button_submit_by_value_and_index(self): + form = self.callFUT(formid='multiple_buttons_form') + self.assertRaises(ValueError, + form.submit, "action", value="activate", + index=0) + class TestResponseFormAttribute(unittest.TestCase): |
