I'm trying to automate a test-case in perl using LWP::UserAgent. I need to check the cookie value post login to the application. Have tried the following sample perl script, but while printing I'm getting output in HASH value :
my $ua = LWP::UserAgent->new;
$ua->agent("MyApp/0.1 ");
my $req = HTTP::Request->new(POST => 'http://' . $test_IP . '/login');
$req->content_type('application/x-www-form-urlencoded');
my $postdata = 'object={"login":{"username":"test","password":"test"}}';
$req->content($postdata);
print "REQUEST is";
print $req;
my $res = $ua->request($req);
print "RESPONSE is";
print $res;
# Check the outcome of the response
if ($res->is_success) {
print LOG $res->headers()->as_string();
}
else {
print $res->status_line, "\n";
}
my $cookie_jar = HTTP::Cookies->new();
print "cookie is";
$cookie_jar->extract_cookies( $res );
print $cookie_jar->extract_cookies( $res );
print $cookie_jar->as_string;
if( $cookie_jar->as_string =~ m/httponly/i )
{
print "Success";
}
else
{
print "FAILED";
}
Have received the output in HASH value :
REQUEST isHTTP::Request=HASH(0x69e85a0)RESPONSE isHTTP::Response=HASH(0x6aa1d98)cookie isHTTP::Response=HASH(0x6aa1d98)
Please suggest how can I login to the application and can check for the required values (here cookie value).