.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "CGI::Test 3pm" .TH CGI::Test 3pm "2016-02-04" "perl v5.22.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" CGI::Test \- CGI regression test framework .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& # In some t/script.t regression test, for instance \& use CGI::Test; \& use Test::More tests => 7; \& \& my $ct = CGI::Test\->new( \& \-base_url => "http://some.server:1234/cgi\-bin", \& \-cgi_dir => "/path/to/cgi\-bin", \& ); \& \& my $page = $ct\->GET("http://some.server:1234/cgi\-bin/script?arg=1"); \& like $page\->content_type, qr|text/html\eb|, "Content type"; \& \& my $form = $page\->forms\->[0]; \& is $form\->action, "/cgi\-bin/some_target", "Form action URI"; \& \& my $menu = $form\->menu_by_name("months"); \& ok $menu\->is_selected("January"), "January selected"; \& ok !$menu\->is_selected("March"), "March not selected"; \& ok $menu\->multiple, "Menu is multi\-choice"; \& \& my $send = $form\->submit_by_name("send_form"); \& ok defined $send, "Send form defined"; \& \& # \& # Now interact with the CGI \& # \& \& $menu\->select("March"); # "click" on the March label \& my $answer = $send\->press; # "click" on the send button \& \& # and make sure we don\*(Aqt get an HTTP error \& ok $answer\->is_ok, "Answer response"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`CGI::Test\*(C'\fR module provides a \s-1CGI\s0 regression test framework which allows you to run your \s-1CGI\s0 programs offline, i.e. outside a web server, and interact with them programmatically, without the need to type data and click from a web browser. .PP If you're using the \f(CW\*(C`CGI\*(C'\fR module, you may be familiar with its offline testing mode. However, this mode is appropriate for simple things, and there is no support for conducting a full session with a stateful script. \&\f(CW\*(C`CGI::Test\*(C'\fR fills this gap by providing the necessary infrastructure to run \s-1CGI\s0 scripts, then parse the output to construct objects that can be queried, and on which you can interact to \*(L"play\*(R" with the script's control widgets, finally submitting data back. And so on... .PP Note that the \s-1CGI\s0 scripts you can test with \f(CW\*(C`CGI::Test\*(C'\fR need not be implemented in Perl at all. As far as this framework is concerned, \s-1CGI\s0 scripts are executables that are run on a CGI-like environment and which produce an output. .PP To use the \f(CW\*(C`CGI::Test\*(C'\fR framework, you need to configure a \f(CW\*(C`CGI::Test\*(C'\fR object to act like a web server, by providing the \s-1URL\s0 base where \&\s-1CGI\s0 scripts lie on this pseudo-server, and which physical directory corresponds to that \s-1URL\s0 base. .PP From then on, you may issue \s-1GET\s0 and \s-1POST\s0 requests giving an \s-1URL,\s0 and the pseudo-server returns a \f(CW\*(C`CGI::Test::Page\*(C'\fR object representing the outcome of the request. This page may be an error, plain text, some binary data, or an \s-1HTML\s0 page (see CGI::Test::Page for details). .PP The latter (an \s-1HTML\s0 page) can contain one or more \s-1CGI\s0 forms (identified by \f(CW\*(C`