Permalink
Browse files

Initial commit.

  • Loading branch information...
kablamo committed Apr 29, 2012
1 parent 1572d70 commit 6ecfe698de260d42b7546756732f41e5eccb5c81
Showing with 336 additions and 0 deletions.
  1. +95 −0 META.json
  2. +241 −0 README.pod
View
@@ -0,0 +1,95 @@
+{
+ "abstract" : "More tools for Selenium testing",
+ "author" : [
+ "Eric Johnson <kablamo at iijo dot nospamthanks dot org>"
+ ],
+ "dynamic_config" : 0,
+ "generated_by" : "Dist::Zilla version 4.300015, CPAN::Meta::Converter version 2.120921",
+ "license" : [
+ "perl_5"
+ ],
+ "meta-spec" : {
+ "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+ "version" : "2"
+ },
+ "name" : "Test-WWW-Selenium-More",
+ "no_index" : {
+ "directory" : [
+ "t",
+ "xt",
+ "examples",
+ "corpus"
+ ],
+ "package" : [
+ "DB"
+ ]
+ },
+ "prereqs" : {
+ "configure" : {
+ "requires" : {
+ "ExtUtils::MakeMaker" : "6.30"
+ }
+ },
+ "runtime" : {
+ "requires" : {
+ "Carp" : "0",
+ "Moose" : "0",
+ "Test::WWW::Selenium" : "0",
+ "namespace::autoclean" : "0",
+ "perl" : "5.010"
+ }
+ },
+ "test" : {
+ "requires" : {
+ "File::Find" : "0",
+ "File::Temp" : "0",
+ "Plack::Builder" : "0",
+ "Test::More" : "0",
+ "Test::Most" : "0",
+ "WWW::Selenium::Util" : "0",
+ "strict" : "0",
+ "warnings" : "0"
+ }
+ }
+ },
+ "provides" : {
+ "Test::WWW::Selenium::More" : {
+ "file" : "lib/Test/WWW/Selenium/More.pm",
+ "version" : "0.001"
+ },
+ "Test::WWW::Selenium::More::Manual" : {
+ "file" : "lib/Test/WWW/Selenium/More/Manual/WritingTests.pod",
+ "version" : "0.001"
+ },
+ "Test::WWW::Selenium::More::Manual::BestPractices" : {
+ "file" : "lib/Test/WWW/Selenium/More/Manual/BestPractices.pod",
+ "version" : "0.001"
+ },
+ "Test::WWW::Selenium::More::Manual::ForTheImpatient" : {
+ "file" : "lib/Test/WWW/Selenium/More/Manual/ForTheImpatient.pod",
+ "version" : "0.001"
+ },
+ "Test::WWW::Selenium::More::Manual::InstallingSeleniumServer" : {
+ "file" : "lib/Test/WWW/Selenium/More/Manual/InstallingSeleniumServer.pod",
+ "version" : "0.001"
+ },
+ "Test::WWW::Selenium::More::Manual::RunningTests" : {
+ "file" : "lib/Test/WWW/Selenium/More/Manual/RunningTests.pod",
+ "version" : "0.001"
+ }
+ },
+ "release_status" : "stable",
+ "resources" : {
+ "bugtracker" : {
+ "web" : "https://github.com/kablamo/Test-WWW-Selenium-More/issues"
+ },
+ "homepage" : "https://github.com/kablamo/Test-WWW-Selenium-More",
+ "repository" : {
+ "type" : "git",
+ "url" : "https://github.com/kablamo/Test-WWW-Selenium-More.git",
+ "web" : "https://github.com/kablamo/Test-WWW-Selenium-More"
+ }
+ },
+ "version" : "0.001"
+}
+
View
@@ -0,0 +1,241 @@
+=pod
+
+=encoding utf-8
+
+=head1 NAME
+
+Test::WWW::Selenium::More - More tools for Selenium testing
+
+=head1 SYNOPSIS
+
+ 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');
+
+=head1 DESCRIPTION
+
+If you are new to this module or Selenium testing in general, see the
+L<Test::WWW::Selenium::More::Manual>.
+
+This module provides method chaining and some useful tools for Selenium
+testing.
+
+This library extends L<Test::WWW::Selenium>. Please see that module's
+documentation as well.
+
+=head1 ATTRIBUTES
+
+=head2 host
+
+The hostname or ip address of the Selenium server. Defaults to 'localhost'.
+
+=head2 port
+
+The port of the Selenium server. Defaults to '4444'.
+
+=head2 browser
+
+The browser to run tests against on the Selenium server. Defaults to
+'*chrome'.
+
+=head2 browser_url
+
+The Selenium server runs tests against this website.
+
+=head2 autostop
+
+When $selenium goes out of scope the browser will be automatically shut down if
+this attribute is set to true. Otherwise stop() must be called explicitly.
+Defaults to 1.
+
+=head2 slow
+
+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.
+
+=head2 stash
+
+A HashRef of saved values. This behaves similar to the Catalyst stash.
+
+=head1 METHODS
+
+=head2 load_data( $file )
+
+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',
+ },
+ ...
+);
+
+=head2 follow_link_ok( $locator, $test_description )
+
+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.
+
+=head2 fill_form_ok( $form )
+
+Returns $self.
+
+$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.
+
+=head2 submit_form_ok( $form )
+
+Returns $self.
+
+$form must be a hashref that looks like this:
+
+ $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.
+
+=head2 wait_for_jquery_ok()
+
+Returns $self.
+
+This blocks until jQuery.active to return false.
+
+=head2 jquery_select_ok($locator, $menu_option)
+
+Returns $self.
+
+$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().
+
+=head2 select_and_page_load_ok($locator, $menu_option)
+
+Returns $self.
+
+$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().
+
+=head2 jquery_click_ok($locator, $menu_option)
+
+Returns $self.
+
+Click whatever is located at $locator. Then wait for jquery to finish by
+calling wait_for_jquery().
+
+=head2 stash_text( $locator => $key )
+
+Returns $self.
+
+Retrieves the value of $locator from selenium and stores it in the stash under
+the name $key.
+
+=head2 stash_location( $key )
+
+Returns $self.
+
+Retrieves the location from selenium and stores it in the stash under the name $key.
+
+=head2 from_stash( $key )
+
+Returns a value from the stash.
+
+=head2 stash( $value => $key )
+
+Returns $self.
+
+Saves $value to the stash under the name $key.
+
+=head2 note( $msg )
+
+Returns $self.
+
+calls Test::Most::note($msg);
+
+=head2 is_text_not_present_ok( $text )
+
+Returns $self.
+
+The opposite of is_text_present_ok().
+
+=head2 note_line( $msg )
+
+Outputs an underlined message, useful for dividing up test output. If no
+message specified, then just prints the separator line.
+
+=head2 download_file_ok($locator)
+
+Parses the href attribute from a link on the current page. Downloads that url
+via javascript's XMLHttpRequest. Checks that response status is 200.
+
+=head2 change_speed($seconds)
+
+This just updates the slow() attribute. The only difference is that it
+returns $self so that you can do method chaining.
+
+=head1 ENVIRONMENT VARIABLES
+
+The following is a list of environment variables that affect the behavior of
+this library. Each corresponds to an attribute (see the ATTRIBUTES
+section).
+
+=head2 SELENIUM_HOST
+
+=head2 SELENIUM_PORT
+
+=head2 SELENIUM_BROWSER
+
+=head2 SELENIUM_BROWSER_URL
+
+=head2 SELENIUM_TIMEOUT
+
+=head2 SELENIUM_AUTOSTOP
+
+=head2 SELENIUM_SLOW
+
+=head1 AUTHOR
+
+Eric Johnson <kablamo at iijo dot nospamthanks dot org>
+
+=head1 COPYRIGHT AND LICENSE
+
+This software is copyright (c) 2012 by Eric Johnson.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+

0 comments on commit 6ecfe69

Please sign in to comment.