File: 03-xpath.t

package info (click to toggle)
libwww-mechanize-treebuilder-perl 1.20000-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 172 kB
  • sloc: perl: 1,418; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use strict;
use warnings;

use FindBin;
use lib "$FindBin::Bin/../t/lib";
use Test::More;

eval { require HTML::TreeBuilder::XPath; };

if ($@) {
 plan skip_all => "This test needs HTML::TreeBuilder::XPath";
} else {
 plan tests => 6
}

use_ok 'WWW::Mechanize::TreeBuilder';
use_ok 'MockMechanize';

my $mech = MockMechanize->new;

WWW::Mechanize::TreeBuilder->meta->apply(
  $mech,
  tree_class => 'HTML::TreeBuilder::XPath'
);

can_ok($mech, "find_xpath" );
$mech->get_ok('/', 'Request ok');

# Check we can use normal TWMC methods
$mech->content_contains('A para');

is( $mech->find_xpath('//h1')->string_value, 'It works', 'find_xpath works');