Revision history for Test-WWW-Selenium-Catalyst
-0.07 - 2009/09/10
- Switch shutDown to shutDownSeleniumServer, which is present in all versions of
SeleniumRC but is the only shut down command that works from 1.0 on.
svn.authors
^\.git
+
+^Test-WWW-Selenium-Catalyst-.*
use strict;
use warnings;
-use inc::Module::Install;
+use inc::Module::Install 0.91;
name 'Test-WWW-Selenium-Catalyst';
perl_version '5.008000';
);
test_requires 'IPC::Cmd' => '0.42';
+test_requires 'Test::More' => '0.92';
WriteAll();
=cut
-our $VERSION = '0.07';
+our $VERSION = '0.06';
=head1 DEVELOPERISH RELEASE
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";
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")
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,
if($www_selenium){
diag("Shutting down Selenium Server $sel_pid") if $DEBUG;
$www_selenium->stop();
- $www_selenium->do_command('shutDownSeleniumServer');
+ # This can fail if a page hasn't been requested yet.
+ eval { $www_selenium->do_command('shutDownSeleniumServer') };
undef $www_selenium;
}
diag("Killing Selenium Server $sel_pid") if $DEBUG;
=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
# 01-live.t
# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
-use Test::More tests => 80;
+use Test::More;
use FindBin;
use lib "$FindBin::Bin/lib";
my $have_apps =
can_run('java') &&
- ( can_run('firefox') || can_run('firefox-bin') );
+ ( can_run('firefox') || can_run('firefox-bin') ) ||
+ $ENV{WE_HAVE_SELENIUM};
SKIP: {
unless ($have_apps) {
} );
};
- skip $@, 80 if $@;
+ skip $@, 79 if $@;
$sel->open_ok('/');
$sel->text_is("link=Click here", "Click here");
}
}
}
+
+done_testing;
-package TestApp;\r
-use Catalyst;\r
-__PACKAGE__->setup; \r
-1;\r
+package TestApp;
+use Catalyst;
+__PACKAGE__->setup;
+1;
-#!/usr/bin/perl\r
-# Root.pm \r
-# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>\r
-\r
-package TestApp::Controller::Root;\r
-use base qw(Catalyst::Controller);\r
-__PACKAGE__->config->{namespace} = q{};\r
-my @words = qw(foo bar baz bat qux quux);\r
-\r
-sub index : Private {\r
- my ($self, $c, @args) = @_;\r
- my $words = $c->uri_for('/words');\r
- $c->response->body(<<"HERE");\r
-<html>\r
-<head>\r
-<title>TestApp</title>\r
-</head>\r
-<body>\r
-<h1>TestApp</h1>\r
-<p>This is the TestApp.</p>\r
-<p><a href="$words">Click here</a> to <i>see</i> some words.</p>\r
-</body>\r
-</html> \r
-HERE\r
-}\r
-\r
-sub words : Local {\r
- my ($self, $c, $times) = @_;\r
- $times ||= 0;\r
- my $html = <<"HEADER";\r
-<html>\r
-<head>\r
-<title>TestApp</title>\r
-</head>\r
-<body>\r
-<h1>TestApp << Words</h1>\r
-<p>Here you'll find all things "words" printed $times time(s)!</p>\r
-<ul>\r
-HEADER\r
- local $" = q{ }; # single space\r
- $html .= " <li>$_: @words</li>\n" for 1..$times;\r
- $html .= <<"FOOTER"; \r
-</ul>\r
-</body>\r
-</html>\r
-FOOTER\r
- $c->response->body($html);\r
-}\r
-\r
-sub null : Path('/favicon.ico'){\r
- my ($self, $c) = @_;\r
- $c->response->status(404); # doesn't exist\r
-}\r
-\r
-1; # true.\r
-\r
+#!/usr/bin/perl
+# Root.pm
+# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
+
+package TestApp::Controller::Root;
+use base qw(Catalyst::Controller);
+__PACKAGE__->config->{namespace} = q{};
+my @words = qw(foo bar baz bat qux quux);
+
+sub index : Private {
+ my ($self, $c, @args) = @_;
+ my $words = $c->uri_for('/words');
+ $c->response->body(<<"HERE");
+<html>
+<head>
+<title>TestApp</title>
+</head>
+<body>
+<h1>TestApp</h1>
+<p>This is the TestApp.</p>
+<p><a href="$words">Click here</a> to <i>see</i> some words.</p>
+</body>
+</html>
+HERE
+}
+
+sub words : Local {
+ my ($self, $c, $times) = @_;
+ $times ||= 0;
+ my $html = <<"HEADER";
+<html>
+<head>
+<title>TestApp</title>
+</head>
+<body>
+<h1>TestApp << Words</h1>
+<p>Here you'll find all things "words" printed $times time(s)!</p>
+<ul>
+HEADER
+ local $" = q{ }; # single space
+ $html .= " <li>$_: @words</li>\n" for 1..$times;
+ $html .= <<"FOOTER";
+</ul>
+</body>
+</html>
+FOOTER
+ $c->response->body($html);
+}
+
+sub null : Path('/favicon.ico'){
+ my ($self, $c) = @_;
+ $c->response->status(404); # doesn't exist
+}
+
+1; # true.
+