Created
December 16, 2010 13:08
-
-
Save adeolaawoyemi/743373 to your computer and use it in GitHub Desktop.
Perl Selenium tests for Pbx home page links
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use lib 'lib'; | |
use Test::WWW::Selenium; | |
use WWW::Selenium::Util qw(server_is_running); | |
use Test::More; | |
my ($host, $port) = server_is_running(); | |
if ($host and $port) { | |
plan tests => 69; | |
} | |
else { | |
plan skip_all => "No selenium server found!"; | |
exit 0; | |
} | |
my $base_url = "http://www.photobox.co.uk/"; | |
my $browser = "*firefox"; | |
my @browsers = qw(*firefox *chrome *safari *iexplore); | |
my $sel = Test::WWW::Selenium->new( | |
host => $host, | |
port => $port, | |
browser => "*firefox", | |
browser_url => $base_url, | |
); | |
my $homepage_links = { | |
welcome => 'link=Welcome', | |
prints => 'link=Prints', | |
calendars => 'link=Calendars', | |
diaries => 'link=Diaries', | |
photo_books => 'link=Photo books', | |
cards => 'link=Cards', | |
wall_decor => 'link=Wall D*cor', | |
home_gifts => 'link=Home gifts', | |
gifts_for_the_kids => 'link=Gifts for the kids', | |
refer_now => 'link=Refer now', | |
join_free => 'pbx_register', | |
site_map_top => q!//div[@id='pbx_top_hat']/div[1]/a[1]/strong!, | |
contact_us_top => q!//div[@id='pbx_top_hat']/div[1]/a[2]/strong!, | |
help_top => q!//div[@id='pbx_top_hat']/div[1]/a[3]/b!, | |
view_basket => q!//a[@id='pbx_basket_link']/span[1]!, | |
view_now_side => q!//div[@id='pbx_homepage_topright_2']/div/a[2]!, | |
discover_now => 'link=Discover now', | |
}; | |
# open homepage | |
$sel->open_ok($base_url); | |
# Iterate over links and return to homepage after each one | |
for my $link (keys %$homepage_links) { | |
next if $link =~ /(help_top)/; | |
print "opening $link...$/"; | |
$sel->click_ok($homepage_links->{$link}); | |
$sel->wait_for_page_to_load_ok("50000"); | |
open_base_url(); | |
} | |
sub open_base_url { | |
$sel->open($base_url); | |
$sel->wait_for_page_to_load("50000"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment