X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FTest%2FWWW%2FSelenium%2FCatalyst.pm;h=c87806db718880716313441a3ea8657f3ea3d9cc;hb=a6c14dc68f42680a7dfda4eed9af846a349887c3;hp=339a4307798c1f7630f4fc492c17336074bfe94d;hpb=a9714b27c04fe65994981b7eff674a8401fc674f;p=catagits%2FTest-WWW-Selenium-Catalyst.git diff --git a/lib/Test/WWW/Selenium/Catalyst.pm b/lib/Test/WWW/Selenium/Catalyst.pm index 339a430..c87806d 100644 --- a/lib/Test/WWW/Selenium/Catalyst.pm +++ b/lib/Test/WWW/Selenium/Catalyst.pm @@ -24,7 +24,7 @@ Test::WWW::Selenium::Catalyst - Test your Catalyst application with Selenium =cut -our $VERSION = '0.05'; +our $VERSION = '0.06'; =head1 DEVELOPERISH RELEASE @@ -174,6 +174,15 @@ sub import { if(defined $d){ $DEBUG = $d; } + + $args{-selenium_args} ||= '-singleWindow'; + + if ($ENV{SELENIUM_SERVER}) { + $args{-no_selenium_server} = 1; + } + elsif ($ENV{SELENIUM_PORT}) { + $args{-selenium_args} .= " -port " . $ENV{SELENIUM_PORT}; + } unless ($args{-no_selenium_server}) { $class->_start_server($args{-selenium_args}) or croak "Couldn't start selenium server"; @@ -220,6 +229,19 @@ sub start { my $sel_class = delete $args->{selenium_class} || 'Test::WWW::Selenium'; my $sel; + if ($ENV{SELENIUM_SERVER}) { + my $uri = $ENV{SELENIUM_SERVER}; + $uri =~ s!^(?:http://)?!http://!; + $uri = new URI($uri); + $args->{selenium_host} = $uri->host; + $args->{selenium_port} = $uri->port; + } + elsif ($ENV{SELENIUM_PORT}) { + $args->{selenium_port} = $ENV{SELENIUM_PORT}; + } + + my $sel_host = delete $args->{selenium_host} || 'localhost'; + my $sel_port = delete $args->{selenium_port} || 4444; while(!$sel && $tries--){ sleep 1; diag("Waiting for selenium server to start") @@ -227,8 +249,8 @@ sub start { eval { $sel = $sel_class->new( - host => delete $args->{selenium_host} || 'localhost', - port => delete $args->{selenium_port} || 4444, + host => $sel_host, + port => $sel_port, browser => '*firefox', browser_url => $uri, auto_stop => 0, @@ -248,7 +270,7 @@ END { diag("Shutting down Selenium Server $sel_pid") if $DEBUG; $www_selenium->stop(); # This can fail if a page hasn't been requested yet. - eval { $www_selenium->do_command('shutDown') }; + eval { $www_selenium->do_command('shutDownSeleniumServer') }; undef $www_selenium; } diag("Killing Selenium Server $sel_pid") if $DEBUG; @@ -342,7 +364,8 @@ Thanks in advance for your contributions! =head1 ACKNOWLEDGEMENTS -Thanks for mst for getting on my case to actually write this thing :) +Thanks for mst for getting on my (jrockway's) case to actually write this thing +:) =head1 COPYRIGHT & LICENSE