GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  WEBDRIVER::TINY (3)

.ds Aq ’

NAME

WebDriver::Tiny - Selenium 2.0 bindings for Perl

CONTENTS

SYNOPSIS



 use WebDriver::Tiny;

 my $drv = WebDriver::Tiny->new;

 # Go to Google.
 $drv->get(https://www.google.co.uk);

 # Type into the search box p, e, r, l, <RETURN>.
 $drv->(input[name=q])->send_keys("perl\N{WD_RETURN}");

 # Click the first perl result (perl.org).
 $drv->(h3.r > a)->click;

 # Save a screenshot of the page.
 $drv->screenshot(/tmp/perl.org.png);



DESCRIPTION

Selenium automates browsers. That’s it! What you do with that power is entirely up to you. Primarily, it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated as well.

Selenium has the support of some of the largest browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.

<http://www.seleniumhq.org>

<B>WARNINGB>: The API of this module is unstable and may change without warning (any change will be appropriately documented in the changelog).

USAGE

The usage of this module varies greatly depending on which backend your’re targetting, below are some examples:

    ChromeDriver



 my $drv = WebDriver::Tiny->new(
     capabilities => {
         chromeOptions => { binary => /usr/bin/google-chrome },
     },
     port => 9515,
 );



    PhantomJS

On the command line:



 phantomjs -w



In Perl code:



 my $drv = WebDriver::Tiny->new( port => 8910 );



    Selenium



 my $drv = WebDriver::Tiny->new(
     capabilities => { browserName => firefox },
     path         => /wd/hub,
     port         => 4444,
 );



IMPORT

This module imports custom charnames for sending keys that would otherwise be hard to represent in text. Each code point falls inside the Unicode Private Use Area (U+E000XU+F8FF), and are as follows:
o WD_NULL
o WD_CANCEL
o WD_HELP
o WD_BACK_SPACE
o WD_TAB
o WD_CLEAR
o WD_RETURN
o WD_ENTER
o WD_SHIFT
o WD_CONTROL
o WD_ALT
o WD_PAUSE
o WD_ESCAPE
o WD_SPACE
o WD_PAGE_UP
o WD_PAGE_DOWN
o WD_END
o WD_HOME
o WD_ARROW_LEFT
o WD_ARROW_UP
o WD_ARROW_RIGHT
o WD_ARROW_DOWN
o WD_INSERT
o WD_DELETE
o WD_SEMICOLON
o WD_EQUALS
o WD_NUMPAD0
o WD_NUMPAD1
o WD_NUMPAD2
o WD_NUMPAD3
o WD_NUMPAD4
o WD_NUMPAD5
o WD_NUMPAD6
o WD_NUMPAD7
o WD_NUMPAD8
o WD_NUMPAD9
o WD_MULTIPLY
o WD_ADD
o WD_SEPARATOR
o WD_SUBTRACT
o WD_DECIMAL
o WD_DIVIDE
o WD_F1
o WD_F2
o WD_F3
o WD_F4
o WD_F5
o WD_F6
o WD_F7
o WD_F8
o WD_F9
o WD_F10
o WD_F11
o WD_F12
o WD_META
o WD_COMMAND
o WD_ZENKAKU_HANKAKU

METHODS

    Driver

new



 my $drv = WebDriver::Tiny->new(
     base_url => ...,
     host     => localhost,
     port     => 4444,
 );



Constructs an instance of this class.

base_url



 my $base_url = $drv->base_url;

 $drv->base_url($base_url);



Accessor to get/set the base_url after instantiation.

    Actions

find



 my @array_of_elements $drv->find(.class);

 my $elements = $drv->find( #id, %args );



Return a collection of matched elements found in the DOM based on passed argument(s). Always returns a collection of WebDriver::Tiny::Elements (sometimes containing no elements), in list context it will return an array of collections, each containing one element.

Due to find being the most common method invoked, the method name can be dropped altogether like so:



 $drv->(#foo);
 $drv->(.bar);



Accepts a mandatory selector parameter and zero or more of the following key/value options:
dies Whether find dies if it fails to find any elements. Defaults to true.
method The matching pattern to use with the given selector - css, ecmascript, link_text, partial_link_text, or xpath. Defaults to ’css’.
sleep How long to sleep before a reattempt of an unsuccessful match. Defaults to 0.1 seconds.
tries Maximum number of attempts to try and find a match. Defaults to 5.

    Alerts

accept_alert



 $drv->accept_alert;



alert_text



 my $text = $drv->alert_text;



dismiss_alert



 $drv->dismiss_alert;



    Cookies

cookie



 # Get cookie "foo".
 my $cookie = $drv->cookie(foo);

 # Set cookie "foo".
 $drv->cookie( foo => value );

 # Or
 $drv->cookie(
     foo      => value,
     domain   => example.com,
     expires  => 123,
     httponly => 0,
     secure   => 1,
 );



cookie_delete



 # Delete all cookies.
 $drv->cookie_delete;

 # Delete cookie "foo".
 $drv->cookie_delete(foo);

 # Delete cookie "bar", and "baz".
 $drv->cookie_delete(qw/bar baz/);



cookies



 # Get a hashref of all cookies.
 my $cookies = $drv->cookies;



    JavaScript

js



 my $return = $drv->js(return "foo");



js_async



 my $return = $drv->js_async(<<JS);
     let callback = arguments[0];

     callback("bar");
 JS



js_phantom



 my $return = $drv->js_phantomjs(return "baz");



    Local Storage

storage



 # Get a hashref of all keys and values in local storage.
 my $storage = $drv->storage;

 # Get a list of all the keys in local storage.
 my @keys = $drv->storage;

 # Get the value of the "foo" key in local storage.
 my $value = $drv->storage(foo);

 # Set the value of the "foo" key in local storage to "bar".
 $drv->storage( foo => bar );



storage_delete

    Navigation

back



 $drv->back;



forward



 $drv->forward;



get



 $drv->get($url);



refresh



 $drv->refresh;



    Properties

capabilities

Hash of the capabilities of the current session.

orientation



 my $orientation = $drv->orientation;

 $drv->orientation($orientation);



source

Get the source code of the current page.

status



 my $status = $drv->status;



title



 my $title = $drv->title;



url



 my $url = $drv->url;



Get the URL of the current page.

user_agent



 my $user_agent = $drv->user_agent;



    Window Management

close_page



 $drv->close_page;



Close the current page.

move_to



 $drv->move_to( $x, $y );



page_ids



 my $ids = $drv->page_ids;



screenshot



 my $png_blob = $drv->screenshot;

 $drv->screenshot(/tmp/foo.png);



switch_page



 $drv->switch_page($page_id);



window_maximize



 $drv->window_maximize;              # Maximize current window.
 $drv->window_maximize(current);   # Same as above.
 $drv->window_maximize(foo);       # Maximize window "foo".



window_position

The following get the window’s position, returning a list of x and y.



 my ( $x, $y ) = $drv->window_position;              # Get position of current window.
 my ( $x, $y ) = $drv->window_position(current);   # Same as above.
 my ( $x, $y ) = $drv->window_position(foo);       # Get position of window "foo".



The following set the window’s position, returning $self to allow chaining.



 $drv->window_position( $x, $y );                    # Set position of current window.
 $drv->window_position( current => $x, $y );         # Same as above.
 $drv->window_position( foo     => $x, $y );         # Set position of window "foo".



window_size

The following get the window’s size, returning a list of width and height.



 my ( $w, $h ) = $drv->window_size;                  # Get size of current window.
 my ( $w, $h ) = $drv->window_size(current);       # Same as above.
 my ( $w, $h ) = $drv->window_size(foo);           # Get size of window "foo".



The following set the window’s size, returning $self to allow chaining.



 $drv->window_size( $w, $h );                        # Set size of current window.
 $drv->window_size( current => $w, $h );             # Same as above.
 $drv->window_size( foo     => $w, $h );             # Set size of window "foo".



SEE ALSO

Selenium::Remote::Driver

COPYRIGHT AND LICENSE

Copyright X 2015 CV-Library Ltd.

This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 WEBDRIVER::TINY (3) 2016-02-24

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.