Test:
Follow links by different methods and check if correct link is opened
Learning:
Solution:
use WWW::Mechanize;
#define number of planned test cases
plan tests => 8;
my $m = WWW::Mechanize->new();
$m->get( "http://www.google.com/" );
#Calling a link by text
$m->follow_link(text=>'Images');
ok($m->title eq "Google Images", "pass");
$m->back();
ok($m->title eq "Google", "pass");
#Calling a link by number
$m->follow_link(n=>1);
ok($m->title eq "Google Images", "pass");
$m->back();
ok($m->title eq "Google", "pass");
#Calling a link by text regex
$m->follow_link(text_regex=>qr/Ima/);
ok($m->title eq "Google Images", "pass");
$m->back();
ok($m->title eq "Google", "pass");
#Calling a link by url regex
$m->follow_link(url_regex=>qr/img/);
ok($m->title eq "Google Images", "pass");
$m->back();
ok($m->title eq "Google", "pass");







