|
1 | 1 | #!/usr/bin/perl
|
2 | 2 | use strict;
|
3 | 3 | use warnings;
|
4 |
| -use Test::More qw/no_plan/; |
5 |
| -use t::Utils qw/method_exists/; |
| 4 | +use Test::More tests => 20; |
6 | 5 | use Test::Exception;
|
7 | 6 |
|
8 | 7 | # The purpose of these tests are to ensure that WWW::Selenium does not
|
@@ -39,14 +38,57 @@ Is_location: {
|
39 | 38 | }
|
40 | 39 |
|
41 | 40 | Get_checked: {
|
42 |
| - # XXX - Not sure what SeleniumServer actually returns here. |
43 | 41 | True: {
|
44 |
| - $sel->_set_mock_response_content('checked'); |
45 |
| - is $sel->get_checked('id=foo'), 'checked'; |
| 42 | + $sel->_set_mock_response_content('true'); |
| 43 | + is $sel->get_checked('id=foo'), 'true'; |
| 44 | + } |
| 45 | + |
| 46 | + False: { |
| 47 | + $sel->_set_mock_response_content('false'); |
| 48 | + is $sel->get_checked('id=foo'), 'false'; |
| 49 | + } |
| 50 | + |
| 51 | + Element_does_not_exist: { |
| 52 | + my $error_msg = "Element id=foo not found"; |
| 53 | + $sel->_set_mock_response_content("ERROR: $error_msg"); |
| 54 | + throws_ok { $sel->get_checked('id=foo') } |
| 55 | + qr/\Q$error_msg\E/; |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +Is_selected: { |
| 60 | + True: { |
| 61 | + $sel->_set_mock_response_content('true'); |
| 62 | + ok $sel->is_selected('id=foo'); |
46 | 63 | }
|
47 | 64 |
|
48 | 65 | False: {
|
49 |
| - $sel->_set_mock_response_content('unchecked'); |
50 |
| - is $sel->get_checked('id=foo'), 'unchecked'; |
| 66 | + $sel->_set_mock_response_content('false'); |
| 67 | + ok !$sel->is_selected('id=foo'); |
| 68 | + } |
| 69 | + |
| 70 | + Element_does_not_exist: { |
| 71 | + my $error_msg = "Element id=foo not found"; |
| 72 | + $sel->_set_mock_response_content("ERROR: $error_msg"); |
| 73 | + throws_ok { $sel->is_selected('id=foo') } |
| 74 | + qr/\Q$error_msg\E/; |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +Get_selected_options: { |
| 79 | + None_selected: { |
| 80 | + $sel->_set_mock_response_content(''); |
| 81 | + is_deeply [$sel->get_selected_options('id=foo')], ['']; |
| 82 | + } |
| 83 | + |
| 84 | + One_selected: { |
| 85 | + $sel->_set_mock_response_content('first response'); |
| 86 | + is_deeply [$sel->get_selected_options('id=foo')], ['first response']; |
| 87 | + } |
| 88 | + |
| 89 | + Two_selected: { |
| 90 | + $sel->_set_mock_response_content('first response,second'); |
| 91 | + is_deeply [$sel->get_selected_options('id=foo')], |
| 92 | + ['first response', 'second']; |
51 | 93 | }
|
52 | 94 | }
|
0 commit comments