Author image APNIC (Asia-Pacific Network Information Centre)
and 1 contributors


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 =
            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:


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 an instance of Test::WWW::Selenium as its only argument.



Takes a hash of arguments:


A Selenium HTML document as a string.


A path to a Selenium HTML document.

Either data or 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, or through the web interface at


You can find documentation for this module with the perldoc command.

    perldoc Test::WWW::Selenium::HTML

You can also look for information at:


 Tom Harrison
 APNIC Software, C<< <cpan at> >>


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.