Skip to content

Commit 7480546

Browse files
hubandroalders
authored andcommitted
adds a test for click_button with coordinates
click_button: fix count of present exclusive options (quick fix) with options "x" and/or "y", @present_exclusive_options would contain "undef" elements, which will be counted too. Therefore click_button with x and y will always have more than > 1 options.
1 parent f091ca6 commit 7480546

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/WWW/Mechanize.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2538,7 +2538,8 @@ sub click_button {
25382538
value => 1,
25392539
);
25402540

2541-
my @present_exclusive_options = @exclusive_options{ keys %args };
2541+
my @present_exclusive_options
2542+
= map { $_ || () } @exclusive_options{ keys %args };
25422543

25432544
if ( scalar @present_exclusive_options > 1 ) {
25442545
$self->die(

t/local/click_button.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ subtest 'multiple button selectors' => sub {
113113
'Dies when multiple button selectors are used';
114114
};
115115

116+
subtest 'click with coordinates' => sub {
117+
$mech->click_button( name => 'button_tag', x => 10, y => 5 );
118+
test_click( $mech, 'button_tag', 'Walk' );
119+
};
120+
116121
sub test_click {
117122
my $mech = shift;
118123
my $name = shift || 'submit';

0 commit comments

Comments
 (0)