Test::WWW::Selenium::More - More useful tools for Selenium testing
version 0.002
use Test::WWW::Selenium::More; Test::WWW::Selenium::More->new ->note('this is a test. this is only a test.') ->open_ok("/") ->is_text_present_ok("Welcome to the internet") ->download_file_ok('link=Download my file');
This library extends Test::WWW::Selenium. Please see that module's documentation.
This library also provides method chaining and extra convenience methods.
See the RUNNING TESTS section of Test::WWW::Selenium::More::Manual.
The following environment variables will affect the behavior of this library. They correspond to the attributes below.
The hostname or ip address of the Selenium RC server
The port of the Selenium RC server
The browser to run tests against on the Selenium RC server
The website to run tests against on the Selenium RC server
If true, when $selenium goes out of scope, the browser will be automatically closed. Otherwise you will need to call stop() explicitly to close the browser.
The number of seconds to sleep after each call to any Test::WWW::Selenium method. This is useful for slowing down tests if you are watching them run in a browser.
Defaults to 0.
A HashRef of saved values. This behaves similar to the Catalyst stash.
Returns a data structure from $file. $file must have valid Perl syntax.
This method is for use with data driven tests. It helps you to separate your Perl code from your test data.
Here is an example of what the contents of $file could look like:
( { name => 'Name of my test', link => 'Click me', text => 'Ponies', }, { name => 'Test downloading stuff', link => 'Download', text => 'Download worked', }, ... );
Returns $self.
This method performs a click_ok on the page element specified by $locator and then does a wait_for_page_to_load(). $test_description is optional. It will be set to something appropriate if you don't set it.
$form must be a hashref that looks like this:
$selenium->fill_form_ok( { select => { locator => value, ... }, input => { locator => value, ... }, } );
The 'select' key indicates dropdown menus that will be selected. The 'input' key indicates text input, hidden input, checkboxes, and radio buttons.
The form is not submitted.
$selenium->submit_form_ok( { select => { locator => value, ... }, input => { locator => value, ... }, click => 'locator', # or 'submit' instead of 'click' } );
$form is simply passed to fill_form_ok(). Afterwards submit_form_ok() looks for 2 keys to process: 'click' and 'submit'. The form is submitted via a click on page element indicated by 'locator' when 'click' is used. The form is submitted without a click when 'submit' is used. This is useful for forms without submit buttons.
This blocks until jQuery.active to return false.
$locator should point to a dropdown menu on the page. This method will select the $menu_option from the dropdown. Then it will call wait_for_jquery().
$locator should point to a dropdown menu on the page. This method will select the $menu_option from the dropdown. Then it will call wait_for_page_to_load().
Click whatever is located at $locator. Then wait for jquery to finish by calling wait_for_jquery().
Retrieves the value of $locator from selenium and stores it in the stash under the name $key.
Retrieves the location from selenium and stores it in the stash under the name $key.
Returns a value from the stash.
Saves $value to the stash under the name $key.
calls Test::Most::note($msg);
The opposite of is_text_present_ok().
Outputs an underlined message, useful for dividing up test output. If no message specified, then just prints the separator line.
Parses the href attribute from a link on the current page. Downloads that url via javascript's XMLHttpRequest. Checks that response status is 200.
This just updates the slow() attribute. The only difference is that it returns $self so that you can do method chaining.
Eric Johnson <kablamo at iijo dot nospamthanks dot org>
This software is copyright (c) 2012 by Foxtons.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Test::WWW::Selenium::More, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::WWW::Selenium::More
CPAN shell
perl -MCPAN -e shell install Test::WWW::Selenium::More
For more information on module installation, please visit the detailed CPAN module installation guide.