From: Jonathan Rockway Date: Thu, 6 Mar 2008 12:29:55 +0000 (-0600) Subject: don't call $sel->start, it breaks things X-Git-Tag: 0.04~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FTest-WWW-Selenium-Catalyst.git;a=commitdiff_plain;h=38cd3a5c41a54640e7e1541fefb30e6b57c7f735 don't call $sel->start, it breaks things 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. --- diff --git a/lib/Test/WWW/Selenium/Catalyst.pm b/lib/Test/WWW/Selenium/Catalyst.pm index 6ab513f..39ceeef 100644 --- a/lib/Test/WWW/Selenium/Catalyst.pm +++ b/lib/Test/WWW/Selenium/Catalyst.pm @@ -16,6 +16,7 @@ my $DEBUG = $ENV{CATALYST_DEBUG}; 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 @@ sub start { 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: $!";