selenium tests
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use Test::More tests => 44;
use WWW::Selenium;
my $pause = 4000;
my $timeout = 0;
my $authed_url = {};
my $browsers = [qw(*firefox *iexplore *opera *safari)];
#$browsers = [qw(*iexplore)]; # 26, 28 seconds
#$browsers = [qw(*firefox)]; # 32, 31 seconds
#$browsers = [qw(*opera)]; # 27, 26 seconds
#$browsers = [qw(*safari)]; # 108, 111 seconds
foreach my $browser_name (@$browsers) {
print "\$browser_name: $browser_name\n";
my $browser = WWW::Selenium->new(
host => "localhost",
port => 4444,
browser => $browser_name,
browser_url => 'http://holaservers.com',
);
$browser->start();
$browser->open('http://holaservers.com?.epoch=' . time);
$browser->wait_for_page_to_load($pause);
$browser->create_cookie("selenium=1");
$browser->click('go');
my $confirmation = $browser->get_confirmation();
ok($confirmation =~ /email is required/, 'email is required');
ok($confirmation =~ /password is required/, 'password is required');
ok($confirmation =~ /agree to the terms/, 'please agree to the terms');
$browser->type('email', 'tester' . '@' . 'holaservers.com');
$browser->click('go');
$confirmation = $browser->get_confirmation();
ok($confirmation =~ /password is required/, 'password is required');
ok($confirmation =~ /agree to the terms/, 'please agree to the terms');
$browser->type('password', 'password');
$browser->click('go');
$confirmation = $browser->get_confirmation();
ok($confirmation =~ /agree to the terms/, 'please agree to the terms');
$browser->click('id=terms');
$browser->click('go');
$browser->pause($pause);
$authed_url->{$browser_name} = $browser->get_alert();
}
foreach my $browser_name (@$browsers) {
my $browser_url = $authed_url->{$browser_name};
ok($browser_url, 'got a browser_url');
print "\$browser_name: $browser_name\n";
my $browser = WWW::Selenium->new(
host => "localhost",
port => 4444,
browser => $browser_name,
browser_url => $browser_url,
);
$browser->start();
$browser->open($browser_url);
$browser->wait_for_page_to_load($pause);
my $subdomain = "$browser_name-" . time;
$subdomain =~ s/\*//g;
ok(!$browser->is_text_present($subdomain), "$subdomain isn't there");
$browser->type('subdomain', $subdomain);
$browser->click('domain_submit');
$browser->pause($pause);
ok($browser->is_text_present($subdomain), "$subdomain is there");
my $domain = "$subdomain.com";
ok(!$browser->is_text_present($domain), "$domain isn't there");
$browser->type('subdomain', '');
$browser->type('domain', $domain);
$browser->click('domain_submit');
$browser->pause($pause);
ok($browser->is_text_present($domain), "$domain is there");
sleep 10;
}
print "elapsed: " . (time - $^T);