Subject: | do_command('open') fails to set _page_opened |
Calling $sel->open('/') sets $self->{_page_opened} but
$sel->do_command('open', '/') does not.
The attached patch contains a test that demonstrates this problem and a
fix that causes the test to pass.
Tom
Subject: | selenium_do_command.patch |
diff -ruN Test-WWW-Selenium-1.12.old/lib/WWW/Selenium.pm Test-WWW-Selenium-1.12/lib/WWW/Selenium.pm
--- Test-WWW-Selenium-1.12.old/lib/WWW/Selenium.pm 2007-03-14 03:23:39.000000000 +0000
+++ Test-WWW-Selenium-1.12/lib/WWW/Selenium.pm 2007-03-27 09:27:48.000000000 +0100
@@ -408,9 +408,10 @@
sub do_command {
my ($self, $command, @args) = @_;
+ $command eq 'open' and $self->{_page_opened} = 1;
+
# Check that user has called open()
my %valid_pre_open_commands = (
- open => 1,
testComplete => 1,
getNewBrowserSession => 1,
);
@@ -1169,7 +1170,6 @@
sub open {
my $self = shift;
- $self->{_page_opened} = 1;
$_[0] ||= '/'; # default to opening site root
$self->do_command("open", @_);
diff -ruN Test-WWW-Selenium-1.12.old/t/selenium-dwim.t Test-WWW-Selenium-1.12/t/selenium-dwim.t
--- Test-WWW-Selenium-1.12.old/t/selenium-dwim.t 2007-01-19 08:35:48.000000000 +0000
+++ Test-WWW-Selenium-1.12/t/selenium-dwim.t 2007-03-27 09:10:03.000000000 +0100
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use warnings;
-use Test::More tests => 12;
+use Test::More tests => 14;
use Test::Exception;
use Test::Mock::LWP;
@@ -47,3 +47,10 @@
$sel = undef;
unlike $Mock_req->new_args->[2], qr/cmd=testComplete/, 'not auto-stop';
}
+
+Do_command_open: {
+ my $sel = t::WWW::Selenium->new;
+ $sel->do_command(qw(open /));
+ $sel->_set_mock_response_content('http://example.com');
+ lives_ok { $sel->get_location };
+}