use Test::Builder; BEGIN { package Test::Builder; use Class::Method::Modifiers; use ExtUtils::MakeMaker qw(prompt); if (!$ENV{AUTOMATED_TESTING}) { around ok => sub { my ($orig, $self) = (shift, shift); my $res = $self->$orig(@_); unless ($res) { if ('y' eq prompt "Well that didn't work, did it. Bail out?", 'y') { exit 255; } } return $res; }; } } my $CAT_SERVER_PORT = 15000 + $<; my $VNC_SERVER_PORT = 5900 + $<; my $SEL_SERVER_PORT = 6900 + $<; sub gimme_table ($file) { my $te = HTML::TableExtract->new; $te->parse(do { local (@ARGV, $/) = ($file); <> }); [ do { my @r = map { [ map { (!defined or $_ eq "\240") ? () : $_ } @$_ ] } ($te->tables)[0]->rows; shift @r; @r; } ] } sub start_server ($port) { my $server = Proc::Background->new( { die_upon_destroy => 1 }, 'script/app_server.pl', '-p', $port ); sleep 3; $server; } sub setup_selenium ($system, $port, $browser, $server_url) { Socialtext::WikiFixture::Selenese->new( selenium => do { my $s = Test::WWW::Selenium->new( host => $system, port => $port, browser => $browser, browser_url => $server_url, ); $s->start; $s } ); } --- t/sel-local-lib/lib/perl5/Socialtext/WikiFixture/Selenese.pm 2007-06-21 18:28:37.000000000 -0400 +++ t/sel-overrides/Socialtext/WikiFixture/Selenese.pm 2010-06-29 14:11:17.000000000 -0400 @@ -128,7 +128,7 @@ } # Try to guess _ok methods - $command .= '_ok' if { map { $_ => 1 } qw(open type) }->{$command}; + $command .= '_ok' if { map { $_ => 1 } qw(open type click) }->{$command}; $self->$command($opt1, $opt2); } @@ -149,6 +149,12 @@ $command = lc($1) . '_like'; } + # mst is guessing. + + if ($command =~ /^(?:assert|verify)_(\w+)$/) { + $command = lc($1) . '_is'; + } + return $command; } @@ -200,6 +206,16 @@ $sel->wait_for_page_to_load_ok($self->{selenium_timeout}, @args); } +sub select_and_wait { + my ($self, $opt1, $opt2) = @_; + my $sel = $self->{selenium}; + + my @args; + push @args, $opt2 if $opt2; + $sel->select_ok($opt1, @args); + $sel->wait_for_page_to_load_ok($self->{selenium_timeout}, @args); +} + =head2 text_present_like() Search entire body for given text