Try to make tests pass
[catagits/Test-WWW-Selenium-Catalyst.git] / t / 01-live.t
CommitLineData
4f6d213e 1#!/usr/bin/perl
2# 01-live.t
3# Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
4
0744bdf6 5use Test::More tests => 80;
4f6d213e 6use FindBin;
7use lib "$FindBin::Bin/lib";
0744bdf6 8
9use IPC::Cmd qw/can_run/;
10
11my $have_apps =
12 can_run('java') &&
a9714b27 13 ( can_run('firefox') || can_run('firefox-bin') ) ||
14 $ENV{WE_HAVE_SELENIUM};
0744bdf6 15
16SKIP: {
17 unless ($have_apps) {
18 # Missing Java or firefox, just do a use_ok test
19 use_ok('Test::WWW::Selenium::Catalyst', 'TestApp',
20 -no_selenium_server => 1);
21 skip "java and firefox requires for further testing", 79;
22 } else {
23 diag("You need to have firefox(-bin) in your path for this to work!");
24
25 my $port = int(20000+rand()*20000);
26 # Try to cope with case when selenium is already running or something is on port 4444
27 my $sel = eval {
28
29 use_ok('Test::WWW::Selenium::Catalyst', 'TestApp',
30 -selenium_args => "-singleWindow -port $port");
31
32 Test::WWW::Selenium::Catalyst->start( {
33 browser => '*firefox',
34 selenium_port => $port
35 } );
36 };
37
a9714b27 38 skip $@, 79 if $@;
0744bdf6 39
40 $sel->open_ok('/');
41 $sel->text_is("link=Click here", "Click here");
42 $sel->click_ok("link=Click here");
43 $sel->wait_for_page_to_load_ok("30000", 'wait');
44 for my $i (1..10){
45 $sel->open_ok("/words/$i");
46 $sel->is_text_present_ok(
47 qq{Here you'll find all things "words" printed $i time(s)!});
48
49 for my $j (1..$i){
50 $sel->is_text_present_ok("$j: foo bar baz bat qux quux");
51 }
4f6d213e 52 }
0744bdf6 53 }
4f6d213e 54}