package Test::WWW::Selenium::More::Manual; __END__ =pod =encoding utf-8 =head1 NAME Test::WWW::Selenium::More::Manual =head1 NAME Test::WWW::Selenium::More::Manual - Testing with Selenium =head1 A BASIC SELENIUM TEST # in the file t/test.t write the following code: use Test::Most; use Test::WWW::Selenium::More; my $s = Test::WWW::Selenium::More->new( host => "localhost", port => 4444, browser => "*firefox", browser_url => "http://www.google.com", default_names => 1, error_callback => sub { ... }, ); $s->open_ok("http://www.google.com", undef, "fetched G's site alright"); $s->type_ok( "q", "hello world"); $s->click_ok("btnG"); $s->wait_for_page_to_load_ok(5000); $s->title_like(qr/Google Search/); $s->error_callback(sub {...}); done_testing; =head1 COMPOSING YOUR TESTS USING ROLES Lets say you have decided to use Test::WWW::Selenium::More, but you want to add some of your own custom methods. Instead of extending Test::WWW::Selenium::More, try grouping your methods by subject using Moose roles. Here is an example. # Create a role use MySeleniumRoles::Auth; use Moose::Role; sub login_ok { my ($self, $username, $password) = @_; $self->open_ok('/login'); $self->is_text_present_ok('Please login thanks'); $self->type_ok('username' => $username); $self->type_ok('password' => $password); $self->follow_link_ok('login'); } sub logout_ok { my ($self, $username, $password) = @_; $self->follow_link_ok('logout'); $self->is_text_present_ok('Goodbye'); } # Subclass Test::WWW::Selenium::More package MySelenium; use Moose; extends 'Test::WWW::Selenium::More'; with 'MySeleniumRoles::Auth'; # Use MySelenium in your test use Test::Most; use MySelenium; MySelenium->new(...) ->login_ok('Bartholomew', 'h@ts'); ->title_like(qr/Thanks for logging in Bartholomew/); done_testing; =head1 METHOD CHAINING TODO =head1 AUTHOR Eric Johnson =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. =cut