X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTest%2FWWW%2FSelenium%2FCatalyst.pm;h=258159cab4d5f1d8fcf2d4d2573875866254e9d5;hb=f781a95505c871f75cc58f61a9bf8122cb57cdbe;hp=53f90c9badac37c380733cf6d42045661b552412;hpb=cba2001554b9f70e9b1baa0476a32e3aa58da483;p=catagits%2FTest-WWW-Selenium-Catalyst.git diff --git a/lib/Test/WWW/Selenium/Catalyst.pm b/lib/Test/WWW/Selenium/Catalyst.pm index 53f90c9..258159c 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 @@ -23,7 +24,7 @@ Test::WWW::Selenium::Catalyst - Test your Catalyst application with Selenium =cut -our $VERSION = '0.01'; +our $VERSION = '0.02'; =head1 DEVELOPERISH RELEASE @@ -93,7 +94,7 @@ sub _start_server { } diag("Selenium running in $$") if $DEBUG; - Alien::SeleniumRC->start() + Alien::SeleniumRC::start() or croak "Can't start Selenium server"; diag("Selenium server $$ going down") if $DEBUG; exit 1; @@ -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: $!";