Test:
Check the title of webpage and display result
Learning:
Use LWP::Simple
It allows you to get content of any webpage by a simple code- get($url)
It allows you to get content of any webpage by a simple code- get($url)
Solution:
use Test::More;
use LWP::Simple;
#define number of planned test cases
plan tests => 1;
#URL under test
my $url = "http://www.google.com";
#getting source code of webpage
my $content = get($url);
#Search string between <title> and</title>
(my $str)= $content =~ /<title>(.*)<\/title>/;
ok($str eq "Google", "Title of $url showed $str");

No comments:
Post a Comment