Subject: | Patch to fix SeleniumRC server starting and stopping |
t/01live.t fails with an error message telling that it couldn't start the Selenium
server for an unknown reason, despite the server running and having started a
browser. This server is also never stopped so the test never finishes because
it's waiting for child processes to exit.
It turns out that the $sel->start; call is not needed at all, and everything works
just as well without it. It's also not mentioned in Test::WWW::Selenium
documentation and examples.
The attached patch fixes this issue and gives a shot at stopping the Selenium
server by issuing a shutDown command before killing the Alien::SeleniumRC
child.
Tests run successfully for me and the module installs with this patch.
Subject: | Test-WWW-Selenium-Catalyst-start-stop-fixes.diff |
diff -Naur Test-WWW-Selenium-Catalyst-0.01/lib/Test/WWW/Selenium/Catalyst.pm Test-WWW-Selenium-Catalyst-0.02/lib/Test/WWW/Selenium/Catalyst.pm
--- Test-WWW-Selenium-Catalyst-0.01/lib/Test/WWW/Selenium/Catalyst.pm 2007-05-27 10:09:53.000000000 +0200
+++ Test-WWW-Selenium-Catalyst-0.02/lib/Test/WWW/Selenium/Catalyst.pm 2008-02-06 17:27:08.000000000 +0100
@@ -16,6 +16,7 @@
my $app; # app name (MyApp)
my $sel_pid; # pid of selenium server
my $app_pid; # pid of myapp server
+my $www_selenium;
=head1 NAME
@@ -160,19 +161,23 @@
new(host => 'localhost',
port => 4444,
browser => $args->{browser} || '*firefox',
- browser_url => 'http://localhost:3000/'
+ browser_url => 'http://localhost:3000/',
+ auto_stop => 0,
);
};
$error = $@;
}
+ croak "Can't start selenium: $error" if $error;
- eval { $sel->start }
- or croak "Can't start selenium: $@ (previous error: $error)";
-
- return $sel;
+ return $www_selenium = $sel;
}
END {
+ if($www_selenium){
+ diag("Shutting down Selenium Server $sel_pid") if $DEBUG;
+ $www_selenium->do_command('shutDown');
+ undef $www_selenium;
+ }
if($sel_pid){
diag("Killing Selenium Server $sel_pid") if $DEBUG;
kill 15, $sel_pid or diag "Killing Selenium: $!";