Luke Closs > Test-WWW-Selenium-1.22 > WWW::Selenium

Download:
Test-WWW-Selenium-1.22.tar.gz

Dependencies

Annotate this POD (4)

CPAN RT

New  3
Open  3
View/Report Bugs
Module Version: 0.93   Source   Latest Release: Test-WWW-Selenium-1.24

NAME ^

WWW::Selenium - Perl Client for the Selenium Remote Control test tool

SYNOPSIS ^

    use WWW::Selenium;
    
    my $sel = WWW::Selenium->new( host => "localhost", 
                                  port => 4444, 
                                  browser => "*iexplore", 
                                  browser_url => "http://www.google.com",
                                );
    
    $sel->start;
    $sel->open("http://www.google.com");
    $sel->type("q", "hello world");
    $sel->click("btnG");
    $sel->wait_for_page_to_load(5000);
    print $sel->get_title;
    $sel->stop;

DESCRIPTION ^

Selenium Remote Control (SRC) is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser. SRC provides a Selenium Server, which can automatically start/stop/control any supported browser. It works by using Selenium Core, a pure-HTML+JS library that performs automated tasks in JavaScript; the Selenium Server communicates directly with the browser using AJAX (XmlHttpRequest).

http://www.openqa.org/selenium-rc/

This module sends commands directly to the Server using simple HTTP GET/POST requests. Using this module together with the Selenium Server, you can automatically control any supported browser.

To use this module, you need to have already downloaded and started the Selenium Server. (The Selenium Server is a Java application.)

METHODS

The following methods are available:

$sel = WWW::Selenium->new( %args )

Constructs a new WWW::Selenium object, specifying a Selenium Server host/port, a command to launch the browser, and a starting URL for the browser.

Options:

  • host

    host is the host name on which the Selenium Server resides.

  • port

    port is the port on which the Selenium Server is listening.

  • browser_url

    browser_url is the starting URL including just a domain name. We'll start the browser pointing at the Selenium resources on this URL, e.g. "http://www.google.com" would send the browser to "http://www.google.com/selenium-server/SeleneseRunner.html"

  • browser or browser_start_command

    This is the command string used to launch the browser, e.g. "*firefox", "*iexplore" or "/usr/bin/firefox"

    This option may be any one of the following:

    • *firefox [absolute path]

      Automatically launch a new Firefox process using a custom Firefox profile. This profile will be automatically configured to use the Selenium Server as a proxy and to have all annoying prompts ("save your password?" "forms are insecure" "make Firefox your default browser?" disabled. You may optionally specify an absolute path to your firefox executable, or just say "*firefox". If no absolute path is specified, we'll look for firefox.exe in a default location (normally c:\program files\mozilla firefox\firefox.exe), which you can override by setting the Java system property firefoxDefaultPath to the correct path to Firefox.

    • *iexplore [absolute path]

      Automatically launch a new Internet Explorer process using custom Windows registry settings. This process will be automatically configured to use the Selenium Server as a proxy and to have all annoying prompts ("save your password?" "forms are insecure" "make Firefox your default browser?" disabled. You may optionally specify an absolute path to your iexplore executable, or just say "*iexplore". If no absolute path is specified, we'll look for iexplore.exe in a default location (normally c:\program files\internet explorer\iexplore.exe), which you can override by setting the Java system property iexploreDefaultPath to the correct path to Internet Explorer.

    • /path/to/my/browser [other arguments]

      You may also simply specify the absolute path to your browser executable, or use a relative path to your executable (which we'll try to find on your path). Warning: If you specify your own custom browser, it's up to you to configure it correctly. At a minimum, you'll need to configure your browser to use the Selenium Server as a proxy, and disable all browser-specific prompting.

  • auto_stop

    Defaults to true, and will attempt to close the browser if the object goes out of scope and stop hasn't been called.

  • keep_alive

    Number of connections LWP should cache. This is just a minor speed improvement. Defaults to 5.

$sel->pause($timeout)

Waits $timeout milliseconds (default: 1 second)

* $sel->is_location($expected_location)

Verify the location of the current page ends with the expected location. If an URL querystring is provided, this is checked as well.

$expected_location is the location to match.

Note: This function is deprecated, use get_location() instead.

* $sel->get_checked($locator)

Gets whether a toggle-button (checkbox/radio) is checked. Fails if the specified element doesn't exist or isn't a toggle-button.

$locator is an element locator pointing to a checkbox or radio button.

Note: This function is deprecated, use is_checked() instead.

* $sel->is_selected($locator, $option_locator)

Verifies that the selected option of a drop-down satisfies the optionSpecifier.

See the select command for more information about option locators.

$locator is an element locator. $option_locator is an option locator, typically just an option label (e.g. "John Smith").

Note: This function is deprecated, use the get_selected_*() methods instead.

* $sel->get_selected_options($locator)

Gets all option labels for selected options in the specified select or multi-select element.

$locator is an element locator.

Note: This function is deprecated, use get_selected_labels() instead.

* $sel->get_absolute_location()

Gets the absolute URL of the current page.

Note: This function is deprecated, use get_location() instead.

SEE ALSO ^

For more information about Selenium Remote Control, visit the website at http://www.openqa.org/selenium-rc/.

BUGS ^

The Selenium Remote Control JIRA issue tracking system is available online at http://jira.openqa.org/browse/SRC.

AUTHOR ^

Perl driver maintained by Luke Closs <selenium-rc@awesnob.com>

Selenium Remote Control maintained by Dan Fabulich <dfabulich@warpmail.net>

LICENSE ^

Copyright (c) 2006 ThoughtWorks, Inc

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

EOT }

sub t_header { return <<'EOT'; #!/usr/bin/perl use strict; use warnings; use Test::More qw/no_plan/;

BEGIN { use lib 't/lib'; use_ok 'LWP::UserAgent'; # mocked use_ok 'HTTP::Response'; # mocked use lib 'lib'; use t::WWW::Selenium; }

my $sel = t::WWW::Selenium->new; isa_ok $sel, 't::WWW::Selenium'; $sel->open;

EOT }

sub test_functions { my @funcs = @_; my $text = ''; for my $f (@funcs) { $text .= qq{\$sel->_method_exists("$f");\n}; } return $text; }

sub read_iedoc_xml { my $iedoc_file = 'target/iedoc.xml'; die "Can't find iedoc.xml" unless -e $iedoc_file; open (my $fh, $iedoc_file) or die "Can't open $iedoc_file: $!"; { local $/ = undef; $iedoc = <$fh>; } close $fh; return $iedoc; }

sub write_file { my ($name, $content) = @_; open(my $fh, ">$name") or die "Can't open $name: $!"; print $fh $content; close $fh or die "Can't write $name: $!"; }

syntax highlighting: