The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::HTML::Form - HTML Testing and Value Extracting

VERSION

0.01

SYNOPSIS

use Test::HTML::Form;

my $filename = 't/form_with_errors.html';

# test functions

title_ok($filename,'Foo Bar','title matches');

no_title($filename,'test site','no english title');

tag_ok($filename, 'p', { class => 'formError', _content => 'There is an error in this form.' }, 'main error message appears as expected' );

no_tag($filename, 'p', { class => 'formError', _content => 'Error' }, 'no unexpected errors' );

text_ok($filename,'koncerty','found text : koncerty'); # check text found in file

no_text($filename,'Concert','no text matching : Concert'); # check text found in file

image_ok($filename,'/images/error.gif','matching image found image in HTML');

link_ok($filename,'/post/foo.html','Found link in HTML');

form_field_value_ok($filename,'category_id', 12345678, undef, 'category_id matches');

form_select_field_ok($filename,{ field_name => $field_name, selected => $field_value, form_name => $form_name}, $description);

form_checkbox_field_ok($filename,{ field_name => $field_name, selected => $field_value, form_name => $form_name}, $description);

# Data extraction functions

my $form_values = Test::HTML::Form->get_form_values({filename => $filename, form_name => 'form1'});

my $posting_id = Test::HTML::Form->extract_text({filename => 'publish.html', pattern => 'Reference :\s(\d+)'});

DESCRIPTION

Test HTML pages and forms, and extract values.

Developed for and released with permission of Slando (http://www.slando.com)

FUNCTIONS

image_ok

image_ok($filename,$image_source,'matching image found image in HTML');

no_image

no_image($filename,$image_source,'no matching image found in HTML');

link_ok($filename,$link_destination,'Found link in HTML');

link_ok($filename,$link_destination,'Link not in HTML');

title_ok

title_ok($filename,'Foo bar home page','title matches');

no_title

tag_ok

tag_ok($filename,'a',{ href => $link },$name); # check matching tag found in file

no_tag

tag_ok($filename,'a',{ href => $link },$name); # check NOT matching tag found in file

text_ok

text_ok($filename,$text,$name); # check text found in file

no_text

no_text($filename,$text,$name); # check text NOT found in file

form_field_value_ok

form_field_value_ok($filename,$field_name, $field_value, $form_name, $description);

form_field_value_ok($filename,$field_name, qr/some pattern/, $form_name, $description);

field value argument can be a string (for exact matches) or a quoted regexp (for pattern matches)

form_select_field_ok

form_select_field_ok($filename,{ field_name => $field_name, selected => $field_value, form_name => $form_name}, $description);

selected field value can be string or quoted regexp

form_checkbox_field_ok

form_checkbox_field_ok($filename,{ field_name => $field_name, selected => $field_value, form_name => $form_name}, $description);

selected field value can be string or quoted regexp

get_form_values

my $form_values = Test::HTML::Form->get_form_values({filename => $filename, form_name => 'form1'});

extract_text

my $posting_id = Test::HTML::Form->extract_text({filename => 'publish.html', pattern => 'Reference :\s(\d+)'});

SEE ALSO

Test::HTML::Content =item HTML::TreeBuilder

AUTHOR

Aaron Trevena

BUGS

Please report any bugs or feature requests to http://rt.cpan.org

COPYRIGHT & LICENSE

Copyright 2008 Slando. Copyright 2009 Aaron Trevena.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.