NAME
Test::HTML::Form - HTML Testing and Value Extracting
VERSION
0.02
SYNOPSIS
use Test::HTML::Form;
my $filename = 't/form_with_errors.html';
# test functions
title_matches($filename,'Foo Bar','title matches');
no_title($filename,'test site','no english title');
tag_matches($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_matches($filename,'koncerty','found text : koncerty'); # check text found in file
no_text($filename,'Concert','no text matching : Concert'); # check text found in file
image_matches($filename,'/images/error.gif','matching image found image in HTML');
link_matches($filename,'/post/foo.html','Found link in HTML');
form_field_value_matches($res,'category_id', 12345678, undef, 'category_id matches');
form_select_field_matches($filename,{ field_name => $field_name, selected => $field_value, form_name => $form_name}, $description);
form_checkbox_field_matches($res,{ 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)
All test functions will take either a filename or an HTTP::Response compatible object (i.e. any object with a content method)
FUNCTIONS
image_matches
image_matches($filename,$image_source,'matching image found image in HTML');
no_image
no_image($res,$image_source,'no matching image found in HTML');
link_matches
link_matches($res,$link_destination,'Found link in HTML');
no_link
link_matches($filename,$link_destination,'Link not in HTML');
title_matches
title_matches($filename,'Foo bar home page','title matches');
no_title
tag_matches
tag_matches($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_matches
text_matches($filename,$text,$name); # check text found in file
no_text
no_text($filename,$text,$name); # check text NOT found in file
form_field_value_matches
form_field_value_matches($filename,$field_name, $field_value, $form_name, $description);
form_field_value_matches($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_matches
form_select_field_matches($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_matches
form_checkbox_field_matches($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
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.