add Xpath lookup method in test lib
This commit is contained in:
parent
5f129f90d4
commit
012b41b2b1
|
@ -57,6 +57,7 @@ use strict;
|
|||
use Data::Dumper;
|
||||
use File::Find;
|
||||
use JSON;
|
||||
use XML::LibXML;
|
||||
use LWP::UserAgent;
|
||||
use Time::Fake;
|
||||
use URI::Escape;
|
||||
|
@ -595,6 +596,17 @@ sub expectCspChildOK {
|
|||
count(1);
|
||||
}
|
||||
|
||||
sub getHtmlElement {
|
||||
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||
my ( $res, $xpath ) = @_;
|
||||
|
||||
# Use recover to ignore parsing errors
|
||||
my $doc =
|
||||
XML::LibXML->new->load_html( string => $res->[2]->[0], recover => 2 );
|
||||
|
||||
return $doc->findnodes($xpath);
|
||||
}
|
||||
|
||||
=head4 getCookies($res)
|
||||
|
||||
Returns an hash ref with names => values of cookies set by server.
|
||||
|
|
Loading…
Reference in New Issue