Test::WWW::Selenium::HTML - Run Selenium HTML tests directly
Provides for running Selenium HTML tests against a Test::WWW::Selenium object and producing TAP output:
my $sel = Test::WWW::Selenium->new( host => "localhost", port => 4444, browser => "*firefox", browser_url => "http://localhost:$port/" ); my $selh = Test::WWW::Selenium::HTML->new($sel); $selh->run(path => "./path/to/selenium/file.html");
run will print TAP output as it progresses through the specified tests. run may be called multiple times, and other tests may occur before and after calls to run. For example, given a Selenium HTML file like so:
... <tr> <td>open</td> <td>test.html</td> <td></td> </tr> <tr> <td>click</td> <td>id=button</td> <td></td> </tr> ...
and a test file (test.t) like so:
... ok(1, "Some test"); $selh->run(path => "./path/to/selenium/file.html"); ok(1, "Some other test"); $selh->run(path => "./path/to/selenium/file.html"); ok(1, "Yet another test"); ...
the output will be:
ok 1 - Some test ok 2 - open(test.html, ) (./path/to/selenium/file.html:14; t/test.t:9) ok 3 - click(id=button, ) (./path/to/selenium/file.html:19; t/test.t:9) ok 4 - Some other test ok 5 - open(test.html, ) (./path/to/selenium/file.html:14; t/test.t:11) ok 6 - click(id=button, ) (./path/to/selenium/file.html:19; t/test.t:11) ok 7 - Yet another test
The Selenium HTML file/string provided to run must be valid XML. This will not normally be a problem, because the HTML produced by the Selenium IDE (via the 'Save Test Case' option) satisfies this requirement.
Takes a hash of arguments:
path must be provided. The relevant Selenium HTML document in both cases must contain Selenium test specifications (the argument here will generally be the result of exporting in HTML format from the Selenium IDE). Runs the test specifications and returns a boolean indicating whether all of the tests were completed successfully.
Returns the current internal variable state as a hashref. Modifications to this hashref will be reflected in the object, so it can be prepopulated (after calling new but before calling run) with variables needed by the tests. Any
store test specifications in the tests proper will cause this hashref to be updated as per the specification.
Controls whether run_test will display the body text on test failure. If passed a true value, this feature is enabled, and vice versa; in both cases, the previous value of this switch is returned. If no argument is passed, returns the value of the switch. Defaults to true.
Tested against Selenium IDE 1.0.12 and Selenium Servers 2.0rc2, 2.8.0, 2.12.0 and 2.19.0.
Please report any bugs or feature requests to
bug-test-www-selenium-html at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-WWW-Selenium-HTML.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Tom Harrison APNIC Software, C<< <cpan at apnic.net> >>
Copyright 2012 APNIC Pty Ltd.
This library is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
The full text of the license can be found in the LICENSE file included with this module.