X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FTest-WWW-Selenium-Catalyst.git;a=blobdiff_plain;f=t%2F01-live.t;h=0cb2d87b968f921d5f46074700bffdf53644f85a;hp=2ad081b26d3acdd21832b4283b08d2cc450ff6e5;hb=0744bdf67407573b567261e48b0068210f2689c6;hpb=13984b27a61e367b800208462ad2e077ab3b87ee diff --git a/t/01-live.t b/t/01-live.t index 2ad081b..0cb2d87 100644 --- a/t/01-live.t +++ b/t/01-live.t @@ -2,26 +2,52 @@ # 01-live.t # Copyright (c) 2006 Jonathan Rockway -use Test::More tests => 79; +use Test::More tests => 80; use FindBin; use lib "$FindBin::Bin/lib"; -use Test::WWW::Selenium::Catalyst 'TestApp', - -selenium_args => '-singleWindow'; - -diag("You need to have firefox-bin in your path for this to work!"); - -my $sel = Test::WWW::Selenium::Catalyst->start({browser => '*firefox'}); - -$sel->open_ok('/'); -$sel->text_is("link=Click here", "Click here"); -$sel->click_ok("link=Click here"); -$sel->wait_for_page_to_load_ok("30000", 'wait'); -for my $i (1..10){ - $sel->open_ok("/words/$i"); - $sel->is_text_present_ok( - qq{Here you'll find all things "words" printed $i time(s)!}); - - for my $j (1..$i){ - $sel->is_text_present_ok("$j: foo bar baz bat qux quux"); + +use IPC::Cmd qw/can_run/; + +my $have_apps = + can_run('java') && + ( can_run('firefox') || can_run('firefox-bin') ); + +SKIP: { + unless ($have_apps) { + # Missing Java or firefox, just do a use_ok test + use_ok('Test::WWW::Selenium::Catalyst', 'TestApp', + -no_selenium_server => 1); + skip "java and firefox requires for further testing", 79; + } else { + diag("You need to have firefox(-bin) in your path for this to work!"); + + my $port = int(20000+rand()*20000); + # Try to cope with case when selenium is already running or something is on port 4444 + my $sel = eval { + + use_ok('Test::WWW::Selenium::Catalyst', 'TestApp', + -selenium_args => "-singleWindow -port $port"); + + Test::WWW::Selenium::Catalyst->start( { + browser => '*firefox', + selenium_port => $port + } ); + }; + + skip $@, 80 if $@; + + $sel->open_ok('/'); + $sel->text_is("link=Click here", "Click here"); + $sel->click_ok("link=Click here"); + $sel->wait_for_page_to_load_ok("30000", 'wait'); + for my $i (1..10){ + $sel->open_ok("/words/$i"); + $sel->is_text_present_ok( + qq{Here you'll find all things "words" printed $i time(s)!}); + + for my $j (1..$i){ + $sel->is_text_present_ok("$j: foo bar baz bat qux quux"); + } } + } }