Seleniu...:Driver(3)

πŸ“¦ version 1.49, in opensuse-leap 16.0

πŸ’… Selenium::Remote::Driver β€” Perl Client for Selenium Remote Driver

Ok so bestie, welcome to Selenium::Remote::Driver, a Perl client for the Selenium Remote Driver (this is the Seleniu...:Driver(3) page from the User Contributed Perl Documentation, iykyk). Buckle up πŸŽ€

✨ VERSION ✨

version 1.49 β€” that's the one, that's the version, no cap.

🌸 SYNOPSIS 🌸

Like, the tiniest possible vibe check of what this thing does:

use Selenium::Remote::Driver;

my $driver = Selenium::Remote::Driver->new;
$driver->get('http://www.google.com');
print $driver->get_title();
$driver->quit();

That's literally it. Slay. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

So Selenium is a test tool, right? It lets you write automated web application UI tests in any programming language, against any HTTP website, using any mainstream JavaScript-enabled browser. Iconic behavior honestly. This module is an implementation of the client for the Remote driver that Selenium provides. And if you wanna find bindings for other languages, they're chillin' right here:

<https://www.seleniumhq.org/download/>

The way this works: this module sends commands directly to the Server using HTTP. Use this module together with the Selenium Server and you can automatically control any supported browser, periodt. But β€” important β€” to use this module you need to have already downloaded and started the Selenium Server (Selenium Server is a Java application, so yes, there's Java involved πŸ™ˆ).


πŸ”₯ USAGE πŸ”₯

Without Standalone Server

As of v0.25, you can use this module without a standalone server β€” meaning you would not need the JRE or the JDK to run your Selenium tests. Cute! See Selenium::Chrome, Selenium::PhantomJS, Selenium::Edge, Selenium::InternetExplorer, and Selenium::Firefox for the deets. And if you want additional browsers besides these? Give us a holler over in Github: <https://github.com/teodesian/Selenium-Remote-Driver/issues>. 🫢

Remote Driver Response

Selenium::Remote::Driver uses the JsonWireProtocol <https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol> and the WC3 WebDriver Protocol <https://www.w3.org/TR/webdriver/> to communicate with the Selenium Server. If an error occurs while executing the command, the server sends back an HTTP error code with a JSON encoded reponse that indicates the precise Response Error Code <https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#response-status-codes>. The module will then croak with the error message associated with this code. If no error occurred, then the subroutine called will return the value sent back from the server (if a return value was sent).

So the rule of thumb when you're invoking methods on the driver: if the method did not croak when called, you can safely assume the command was successful β€” even if nothing was returned by the method. No croak = no problem πŸ’–

WebElement

Selenium Webdriver represents all the HTML elements as WebElement, which is in turn represented by Selenium::Remote::WebElement. So any method that deals with WebElements will return and/or expect a WebElement object. The POD for that module describes all the methods that perform various actions on the WebElements, like click, submit, etc.

To interact with any WebElement you have to first "find" it β€” read the POD for find_element or find_elements for further info. Once you find the required element, then you can perform various actions. If you don't call find_* first, all your further actions will fail for that element 😭. And finally, just remember: you don't have to instantiate WebElement objects at all β€” they will be automatically created when you use the find_* methods. Main character energy, they just show up.

A sub-class of Selenium::Remote::WebElement may be used instead of Selenium::Remote::WebElement, by providing that class name as an option to the constructor:

my $driver = Selenium::Remote::Driver->new( webelement_class => ... );

For example, a testing-subclass may extend the web-element object with testing methods. Obsessed, honestly.

LWP Read Timeout errors

It's possible to make Selenium calls that take longer than the default LWP::UserAgent timeout. For example, setting the asynchronous script timeout greater than the LWP::UserAgent timeout and then executing a long running asynchronous snippet of javascript will immediately trigger an error like:

Error while executing command: executeAsyncScript: Server returned
error message read timeout at...

You can get around this by configuring LWP's timeout value, either by constructing your own LWP and passing it in to ::Driver during instantiation:

my $timeout_ua = LWP::UserAgent->new;
$timeout_ua->timeout(360); # this value is in seconds!
my $d = Selenium::Remote::Driver->new( ua => $timeout_ua );

or by configuring the timeout on the fly as necessary:

use feature qw/say/;
use Selenium::Remote::Driver;

my $d = Selenium::Remote::Driver->new;
say $d->ua->timeout; # 180 seconds is the default

$d->ua->timeout(2); # LWP wants seconds, not milliseconds!
$d->set_timeout('script', 1000); # S::R::D wants milliseconds!

# Async scripts only return when the callback is invoked. Since there
# is no callback here, Selenium will block for the entire duration of
# the async timeout script. This will hit Selenium's async script
# timeout before hitting LWP::UserAgent's read timeout
$d->execute_async_script('return "hello"');

$d->quit;
Bestie, watch the units. LWP is out here living in seconds, S::R::D is living in milliseconds. Don't mix them up or you'll be debugging for an hour πŸ’€

🧚 TESTING 🧚

If you're writing automated tests using this module, you may be interested in Test::Selenium::Remote::Driver, which is also included in this distribution. It includes convenience testing methods for many of the selenum methods available here. Handy!

Your other option is to use this module in conjunction with your choice of testing modules, like Test::Spec or Test::More, as you please. Live your life 🌈


πŸ‘‘ WC3 WEBDRIVER COMPATIBILITY πŸ‘‘

WC3 Webdriver is a constantly evolving standard, so some things may or may not work at any given time. It's giving "we're all just doing our best" πŸ’€

Furthermore, out of date drivers probably identify as WD3, while only implementing a few methods and retaining JSONWire functionality. One way of dealing with this is setting:

$driver->{is_wd3} = 0

Of course, this will prevent access of any new WC3 methods, but will probably make your tests pass until your browser's driver gets it's act together. πŸ™ˆ

There are also some JSONWire behaviors that we emulate in methods, such as Selenium::Remote::WebElement::get_attribute. You can get around that by passing an extra flag to the sub, or setting:

$driver->{emulate_jsonwire} = 0;

When in WC3 Webdriver mode.

πŸ” FINDERS πŸ”

This constant is a hashref map of the old element finder aliases from wd2 to wd3.

use Data::Dumper;
print Dumper($Selenium::Remote::Driver::FINDERS);

πŸ“‹ WC3 WEBDRIVER CURRENT STATUS πŸ“‹

That said, the following 'sanity tests' in the at/ (acceptance test) directory of the module passed on the following versions:

  • Selenium Server: 3.8.1 β€” all tests
  • geckodriver: 0.19.1 β€” at/sanity.test, at/firefox.test (Selenium::Firefox)
  • chromedriver: 2.35 β€” at/sanity-chrome.test, at/chrome.test (Selenium::Chrome)
  • edgedriver: 5.16299 β€” at/sanity-edge.test
  • InternetExplorerDriver : 3.8.1 β€” at/sanity-ie.test (be sure to enable 'allow local files to run active content in your 'advanced settings' pane)
  • safaridriver : 11.0.2 β€” at/sanity-safari.test (be sure to enable 'allow automated testing' in the developer menu) β€” it appears WC3 spec is unimplemented

These tests are intended to be run directly against a working selenium server on the local host with said drivers configured.

If you are curious as to what 'works and does not' on your driver versions (and a few other quirks), it is strongly encouraged you look at where the test calls the methods you are interested in.

While other browsers/drivers (especially legacy ones) likely work fine as well, any new browser/driver will likely have problems if it's not listed above.

There is also a 'legacy.test' file available to run against old browsers/selenium (2.x servers, pre geckodriver). This should only be used to verify backwards-compatibility has not been broken.

🦊 Firefox Notes 🦊

If you are intending to pass extra_capabilities to firefox on a WD3 enabled server with geckodriver, you MUST do the following:

$Selenium::Remote::Driver::FORCE_WD3=1;

This is because the gecko driver prefers legacy capabilities, both of which are normally passed for compatibility reasons. So yeah, you gotta force it ✨

πŸ’› Chrome Notes πŸ’›

Use the option goog:chromeOptions instead of chromeOptions, if you are intending to pass extra_capabilities on a WD3 enabled server with chromedriver enabled.

https://sites.google.com/a/chromium.org/chromedriver/capabilities

Also, if you instantiate the object in WC3 mode (which is the default), the remote driver will throw exceptions you have no choice but to catch, rather than falling back to JSONWire methods where applicable like geckodriver does. No chill whatsoever 😭

As of chrome 75 (and it's appropriate driver versions), the WC3 spec has finally been implemented. As such, to use chrome older than this, you will have to manually force on JSONWire mode:

$Selenium::Remote::Driver::FORCE_WD2=1;

βš™οΈ Notes on Running Selenium at Scale via selenium.jar βš™οΈ

When running many, many tests in parallel you can eventually reach resource exhaustion. You have to instruct the Selenium JAR to do some cleanup to avoid explosions πŸ’₯

Inside of your selenium server's node.json (running a grid), you would put in the following:

"configuration" : { "cleanUpCycle":2000 }

Or run the selenium jar with the -cleanupCycle parameter. Of course use whatever # of seconds is appropriate to your situation. iykyk.


πŸŽ€ CONSTRUCTOR πŸŽ€

new

Dies if communication with the selenium server cannot be established.

Input: (all optional)

Desired capabilities - HASH - Following options are accepted:

  • remote_server_addr β€” <string> β€” IP or FQDN of the Webdriver server machine. Default: 'localhost' 🏠
  • port β€” <string> β€” Port on which the Webdriver server is listening. Default: 4444 πŸ”Œ
  • browser_name β€” <string> β€” desired browser string: {phantomjs|firefox|internet explorer|MicrosoftEdge|safari|htmlunit|iphone|chrome} 🌐
  • version β€” <string> β€” desired browser version number 🏷️
  • platform β€” <string> β€” desired platform: {WINDOWS|XP|VISTA|MAC|LINUX|UNIX|ANY} πŸ’»
  • accept_ssl_certs β€” <boolean> β€” whether SSL certs should be accepted, default is true πŸ”
  • firefox_profile β€” Profile β€” Use Selenium::Firefox::Profile to create a Firefox profile for the browser to use 🦊
  • javascript β€” <boolean> β€” Whether or not to use Javascript. You probably won't disable this, as you would be using WWW::Mechanize instead. Default: True ✨
  • auto_close β€” <boolean> β€” Whether to automatically close the browser session on the server when the object goes out of scope. Default: False πŸšͺ
  • default_finder β€” <string> β€” Default method by which to evaluate selectors. Default: 'xpath' πŸ”Ž
  • session_id β€” <string> β€” Provide a Session ID to highjack a browser session on the remote server. Useful for micro-optimizers. Default: undef πŸ•΅οΈβ€β™€οΈ
  • pageLoadStrategy β€” STRING β€” OPTIONAL, 'normal|eager|none'. default 'normal'. WebDriver3 only ⏳
  • extra_capabilities β€” HASH β€” Any other extra capabilities. Accepted keys will vary by browser. If firefox_profile is passed, the args (or profile) key will be overwritten, depending on how it was passed πŸŽ›οΈ
  • debug β€” BOOL β€” Turn Debug mode on from the start if true, rather than having to call debug_on() πŸ›

On WebDriver3 the <pink>'extra_capabilities'</pink> will be automatically converted into the parameter needed by your browser. For example, extra_capabilities is passed to the server as the moz:firefoxOptions parameter. iykyk πŸ’…

You can also specify some options in the constructor hash that are not part of the browser-related desired capabilities. bestie, these are the extra little knobs: πŸŽ€

  • auto_close β€” <boolean> β€” whether driver should end session on remote server on close πŸšͺ
  • base_url β€” <string> β€” OPTIONAL, base url for the website Selenium acts on. This can save you from repeating the domain in every call to $driver->get() 🌍
  • default_finder β€” <string> β€” choose default finder used for find_element* {class|class_name|css|id|link|link_text|name|partial_link_text|tag_name|xpath} πŸ”
  • inner_window_size β€” <aref[Int]> β€” An array ref [ height, width ] that the browser window should use as its initial size immediately after instantiation πŸͺŸ
  • error_handler β€” CODEREF β€” A CODEREF that we will call in event of any exceptions. See "error_handler" for more details 🚨
  • webelement_class β€” <string> β€” sub-class of Selenium::Remote::WebElement if you wish to use an alternate WebElement class 🧩
  • ua β€” LWP::UserAgent instance β€” if you wish to use a specific $ua, like from Test::LWP::UserAgent πŸ›°οΈ
  • proxy β€” HASH β€” Proxy configuration with the following keys:
    • proxyType β€” <string> β€” REQUIRED, Possible values are:
      • direct β€” A direct connection - no proxy in use,
      • manual β€” Manual proxy settings configured, e.g. setting a proxy for HTTP, a proxy for FTP, etc,
      • pac β€” Proxy autoconfiguration from a URL,
      • autodetect β€” proxy autodetection, probably with WPAD,
      • system β€” Use system settings
    • proxyAutoconfigUrl β€” <string> β€” REQUIRED if proxyType is 'pac', ignored otherwise. Expected format: http://hostname.com:1234/pacfile or file:///path/to/pacfile
    • ftpProxy β€” <string> β€” OPTIONAL, ignored if proxyType is not 'manual'. Expected format: hostname.com:1234
    • httpProxy β€” <string> β€” OPTIONAL, ignored if proxyType is not 'manual'. Expected format: hostname.com:1234
    • sslProxy β€” <string> β€” OPTIONAL, ignored if proxyType is not 'manual'. Expected format: hostname.com:1234
    • socksProxy β€” <string> β€” OPTIONAL, ignored if proxyType is not 'manual'. Expected format: hostname.com:1234. WebDriver 3 only.
    • socksVersion β€” <int> β€” OPTIONAL, ignored if proxyType is not 'manual'. WebDriver 3 only.
    • noProxy β€” <ARRAY> β€” OPTIONAL, list of URLs to bypass the proxy for. WebDriver3 only.
    • firefox_profile β€” <string> β€” Base64 encoded ZIP file of a firefox profile directory, for use when you don't want/need Selenium::Firefox::Profile.

Output: a Selenium::Remote::Driver object πŸ’–

Usage: okay these are the little starter-pack snippets, no cap ✨

my $driver = Selenium::Remote::Driver->new;

#or
my $driver = Selenium::Remote::Driver->new('browser_name' => 'firefox',
                                           'platform'     => 'MAC');

#or (for Firefox 47 or lower on Selenium 3+)
my $driver = Selenium::Remote::Driver->new('browser_name' => 'firefox',
                                           'platform'     => 'MAC',
                                           'extra_capabilities' => {
                                                'marionette' => \0,
                                          });

#or
my $driver = Selenium::Remote::Driver->new('remote_server_addr' => '10.10.1.1',
                                           'port'               => '2222',
                                           'auto_close'         => 0);

#or
my $driver = Selenium::Remote::Driver->new('browser_name' =>'chrome',
                                           'extra_capabilities' => {
                                               'goog:chromeOptions' => {
                                                   'args'  => [
                                                       'window-size=1260,960',
                                                       'incognito'
                                                   ],
                                                   'prefs' => {
                                                       'session' => {
                                                           'restore_on_startup' => 4,
                                                           'urls_to_restore_on_startup' => [
                                                               'http://www.google.com',
                                                               'http://docs.seleniumhq.org'
                                                           ]},
                                                       'first_run_tabs' => [
                                                           'http://www.google.com',
                                                           'http://docs.seleniumhq.org'
                                                       ]
                                                   }
                                               }
                                           });

#or
my $driver = Selenium::Remote::Driver->new('proxy' => {'proxyType' => 'manual', 'httpProxy' => 'myproxy.com:1234'});

#or
my $driver = Selenium::Remote::Driver->new('default_finder' => 'css');

🚨 error_handler & clear_error_handler 🚨

OPTIONAL constructor arg & associated setter/clearer: if you wish to install your own error handler, you may pass a code ref in to "error_handler" during instantiation like follows:

my $driver = Selenium::Remote::Driver->new(
    error_handler => sub { print $_[1]; croak 'goodbye'; }
);

Additionally, you can set and/or clear it at any time on an already-instantiated driver:

# later, change the error handler to something else
$driver->error_handler( sub { print $_[1]; croak 'hello'; } );

# stop handling errors manually and use the default S:R:D behavior
# (we will croak about the exception)
$driver->clear_error_handler;

Your error handler will receive three arguments: the first argument is the $driver object itself, and the second argument is the exception message and stack trace in one multiline string. The final argument(s) are the argument array to the command just executed. tea spilled, bestie β˜•

N.B.: If you set your own error handler, you are entirely responsible for handling webdriver exceptions, including croaking behavior. That is, when you set an error handler, we will no longer croak on Webdriver exceptions - it's up to you to do so. For consistency with the standard S:R:D behavior, we recommend your error handler also croak when it's done, especially since your test shouldn't be running into unexpected errors. Catching specific or desired errors in your error handler makes sense, but not croaking at all can leave you in unfamiliar territory. Reaching an unexpected exception might mean your test has gone off the rails, and the further your test gets from the source of the exception, the harder it will be to debug. this is the serious bit, fr fr 😭
N.B.: Four methods will still croak on their own: find_element, find_elements, find_child_element, and find_child_elements. If these methods throw a Webdriver Exception, your error handler will still be invoked inside an eval, and then they'll croak with their own error message that indicates the locator and strategy used. So, your strategies for avoiding exceptions when finding elements do not change (either use find_elements and check the returned array size, wrap your calls to find_element* in an eval, or use the parameterized versions find_element_*). πŸ’€

🧚 new_from_caps 🧚

Description: For experienced users who want complete control over the desired capabilities, use this alternative constructor along with the desired_capabilities hash key in the init hash. Unlike "new", this constructor will not assume any defaults for your desired capabilities. main character constructor energy πŸ‘‘

This alternate constructor IGNORES all other browser-related desiredCapability options; the only options that will be respected are those that are NOT part of the Capabilities JSON Object as described in the Json Wire Protocol. 🚫

Input: The only respected keys in the input hash are:

  • desired_capabilities β€” HASHREF β€” defaults to {}
  • remote_server_addr β€” STRING β€” defaults to localhost
  • port β€” INTEGER β€” defaults to 4444
  • default_finder β€” STRING β€” defaults to xpath
  • webelement_class β€” STRING β€” defaults to Selenium::Remote::WebElement
  • auto_close β€” BOOLEAN β€” defaults to 1
  • error_handler β€” CODEREF β€” defaults to croaking on exceptions

Except for desired_capabilities, these keys perform exactly the same as listed in the regular "new" constructor. 🫢

okay so the hashref you pass in as desired_capabilities? it literally only gets json encoded before being handed to the Selenium server β€” that's it, that's the whole treatment. no default options of any sort will be added. none. zero. 😭

which means you are the one on the hook for handling normalization and casing of the input options (like "browser_name" vs "browserName") and taking care of things like encoding the firefox profile if that applies to you. more info about the desired capabilities object lives on the Selenium wiki:

https://code.google.com/p/selenium/wiki/JsonWireProtocol#Capabilities_JSON_Object

Output:

Remote Driver object

Usage:

my $driver = Selenium::Remote::Driver->new_from_caps(
    'desired_capabilities' => {'browserName' => 'firefox'}
);

the above would generate a POST to the webdriver server at localhost:4444 with the exact payload of '{"desiredCapabilities": {"browserName": "firefox" }}'. exact exact. no extra seasoning whatsoever πŸ’…


✨ METHODS ✨

new_session (extra_capabilities)

makes a brand new session on the server. it's called by new(), so this is not intended for regular use, bestie.

but it is occasionally handy for recovering from browser crashes 🫢

DANGER DANGER DANGER this will throw away your old session if you have not closed it! DANGER DANGER DANGER

new_desired_session (capabilities)

basically the same thing as new_session, but with caps. sort of an analog to new_from_caps. πŸŽ€

is_webdriver_3

prints whether the server (or browser) thinks it's implemented webdriver 3. if this returns true, webdriver 3 methods get used in the case an action exists in Selenium::Remote::Spec for the method you're trying to call. if the method you're calling has no webdriver 3 equivalent (or browser extension), then the legacy commands implemented in Selenium::Remote::Commands get used instead.

and yes, note how I said thinks up there πŸ‘€ in the case you want to force usage of legacy methods, set $driver->{is_wd3} to work around various browser issues.

debug_on

Description:

turns on debugging mode, and the driver will print extra info like request and response to stdout. super useful when you wanna see what's being sent to the server & what response you're getting back. πŸ”₯

Usage:

$driver->debug_on;

debug_off

Description:

turns the debugging mode off. that's it. that's the method.

Usage:

$driver->debug_off;

get_sessions

Description:

returns a list of the currently active sessions. each session comes back as an array of Hashes with these keys:

  • 'id' : The session ID
  • 'capabilities : An object describing session's capabilities

Output:

Array of Hashes

Usage:

print Dumper $driver->get_sessions();

status

Description:

query the server's current status. all server implementations should return two basic objects describing the server's current platform and when the server was built. πŸ¦‹

Output:

Hash ref

Usage:

print Dumper $driver->status;

get_alert_text

Description:

gets the text of the currently displayed JavaScript alert(), confirm() or prompt() dialog.

Example:

my $string = $driver->get_alert_text;

send_keys_to_active_element

Description:

send a sequence of key strokes to the active element. this command is similar to the send keys command in every aspect except the implicit termination: the modifiers are not released at the end of the call. instead, the state of the modifier keys is kept between calls, so mouse interactions can be performed while modifier keys are depressed. kind of iconic ngl πŸ‘‘

Compatibility:

on webdriver 3 servers, don't use this to send modifier keys; use send_modifier instead.

Input: 1

Required:

  • {ARRAY | STRING} β€” Array of strings or a string.

Usage:

$driver->send_keys_to_active_element('abcd', 'efg');
$driver->send_keys_to_active_element('hijk');

or

# include the WDKeys module
use Selenium::Remote::WDKeys;
$driver->send_keys_to_active_element(KEYS->{'space'}, KEYS->{'enter'});

send_keys_to_alert

synonymous with send_keys_to_prompt. same thing, different name, we love an alias πŸ’œ

send_keys_to_prompt

Description:

sends keystrokes to a JavaScript prompt() dialog.

Input:

{string} keys to send

Example:

$driver->send_keys_to_prompt('hello world');

or

ok($driver->get_alert_text eq 'Please Input your name','prompt appears');
$driver->send_keys_to_alert("Larry Wall");
$driver->accept_alert;

accept_alert

Description:

accepts the currently displayed alert dialog. usually this is equivalent to clicking the 'OK' button in the dialog.

Example:

$driver->accept_alert;

dismiss_alert

Description:

dismisses the currently displayed alert dialog. for confirm() and prompt() dialogs, this is equivalent to clicking the 'Cancel' button. for alert() dialogs, this is equivalent to clicking the 'OK' button. yeah, it flips, don't ask πŸ™ˆ

Example:

$driver->dismiss_alert;

general_action

provide an 'actions definition' hash to make webdriver use input devices. given the spec for the structure of this data is 'non normative', it is left as an exercise to the reader what that means as to how to use this function. 😭

that said, it seems most of the data looks something like this:

$driver->general_action( actions => [{
    type => 'pointer|key|none|somethingElseSuperSpecialDefinedByYourBrowserDriver',
    id => MUST be mouse|key|none|other.  And by 'other' I mean anything else.  The first 3 are 'special' in that they are used in the global actions queue.
          If you want say, another mouse action to execute in parallel to other mouse actions (to simulate multi-touch, for example), call your action 'otherMouseAction' or something.
    parameters => {
        someOption => "basically these are global parameters used by all steps in the forthcoming "action chain".
    },
    actions => [
        {
            type => "keyUp|KeyDown if key, pointerUp|pointerDown|pointerMove|pointerCancel if pointer, pause if any type",
            key => A raw keycode or character from the keyboard if this is a key event,
            duration => how many 'ticks' this action should take, you probably want this to be 0 all of the time unless you are evading Software debounce.
            button => what number button if you are using a pointer (this sounds terribly like it might be re-purposed to be a joypad in the future sometime)
            origin => Point of Origin if moving a pointer around
            x => unit vector to travel along x-axis if pointerMove event
            y => unit vector to travel along y-axis if pointerMove event
        },
        ...
    ]
    },
    ...
    ]
)

only available on WebDriver3 capable selenium servers. ⭐

if you've called any legacy shim, such as mouse_move_to_location() previously, your actions passed will be appended to the existing actions queue. called with no arguments, it simply executes the existing action queue.

if you're looking for pre-baked action chains that aren't currently part of Selenium::Remote::Driver, consider Selenium::ActionChains, which is shipped with this distribution instead. 🎁

COMPATIBILITY

like most places, the WC3 standard is openly ignored by the driver binaries. generally an "actions" object will only accept:

{ type => ..., value => ... }

when using the direct drivers (E.G. Selenium::Chrome, Selenium::Firefox). this is not documented anywhere but here, as far as I can tell. iykyk πŸ’€

release_general_action

nukes all input device state (modifier key up/down, pointer button up/down, pointer location, and other device state) from orbit. call it if you forget to do a *Up event in your provided action chains, or just to save time. πŸ”₯

also clears the current actions queue.

only available on WebDriver3 capable selenium servers.

mouse_move_to_location

Description:

move the mouse by an offset of the specified element. if no element is specified, the move is relative to the current mouse cursor. if an element is provided but no offset, the mouse will be moved to the center of the element. if the element is not visible, it will be scrolled into view. ✨

Compatibility:

due to limitations in the Webdriver 3 API, mouse movements have to be executed 'lazily' e.g. only right before a click() event occurs. this is because there's no longer any persistent mouse location state; mouse movements are now totally atomic. this has several problematic aspects; for one, I can't think of a way to both hover an element and then do another action relying on the element staying hover()ed, aside from using javascript workarounds. 😭

Output:

STRING -

Usage:

# element - the element to move to. If not specified or is null, the offset is relative to current position of the mouse.
# xoffset - X offset to move to, relative to the top-left corner of the element. If not specified, the mouse will move to the middle of the element.
# yoffset - Y offset to move to, relative to the top-left corner of the element. If not specified, the mouse will move to the middle of the element.

print $driver->mouse_move_to_location(element => e, xoffset => x, yoffset => y);

move_to

synonymous with mouse_move_to_location. we stan a short alias 🫢

get_capabilities

Description:

retrieve the capabilities of the specified session.

Output:

HASH of all the capabilities.

Usage:

my $capab = $driver->get_capabilities();
print Dumper($capab);

get_timeouts

Description:

get the currently configured values (ms) for the page load, script and implicit timeouts.

Compatibility:

only available on WebDriver3 enabled selenium servers.

Usage:

$driver->get_timeouts();

set_timeout

Description:

configure the amount of time that a particular type of operation can execute for before they're aborted and a |Timeout| error is returned to the client.

Input:

  • type β€” <STRING> β€” the type of operation to set the timeout for. valid values are:
    • "script" : for script timeouts,
    • "implicit" : for modifying the implicit wait timeout
    • "page load" : for setting a page load timeout.
  • ms β€” <NUMBER> β€” the amount of time, in milliseconds, that time-limited commands are permitted to run.

Usage:

$driver->set_timeout('script', 1000);

set_async_script_timeout

Description: bestie, this one sets the amount of time, in milliseconds, that asynchronous scripts executed by execute_async_script() are allowed to run before they get aborted and a |Timeout| error is returned to the client. ⏰

Input:

  • ms β€” <NUMBER> β€” the amount of time, in milliseconds, that time-limited commands are permitted to run.

Usage:

$driver->set_async_script_timeout(1000);

set_implicit_wait_timeout

Description: sets how long the driver should wait when it's out here searching for elements. πŸ” When searching for a single element, the driver will poll the page until an element is found or the timeout expires β€” whichever occurs first, no cap. When searching for multiple elements, the driver should poll the page until at least one element is found or the timeout expires, at which point it will return an empty list. And if this method is never called? The driver defaults to an implicit wait of 0ms. literally zero patience.

This is exactly equivalent to calling set_timeout with a type arg of "implicit". ✨

Input: time in milliseconds.

Output: server Response Hash with no data returned back from the server.

Usage:

$driver->set_implicit_wait_timeout(10);

pause

Description: pauses execution for a specified interval of milliseconds. 😴

Usage:

$driver->pause(10000);  # 10 second delay
$driver->pause();       #  1 second delay default
DEPRECATED: consider using Time::HiRes instead. fr fr, it's giving legacy.

close

Description: closes the current window. bye bestie πŸ‘‹

Usage:

$driver->close();

or

#close a popup window
my $handles = $driver->get_window_handles;
$driver->switch_to_window($handles->[1]);
$driver->close();
$driver->switch_to_window($handles->[0]);

quit

Description: DELETE the session, closing open browsers. πŸšͺ We will try to call this on our way down when we get destroyed, but in the event that we are demolished during global destruction, we will not be able to close the browser. For your own unattended and/or complicated tests, we recommend explicitly calling quit to make sure you're not leaving orphan browsers around. nobody wants stray browser children wandering the filesystem 😭

Note that as a Moo class, we use a subroutine called DEMOLISH that takes the place of DESTROY; for more information, see https://metacpan.org/pod/Moo#DEMOLISH.

Usage:

$driver->quit();

get_current_window_handle

Description: retrieves the current window handle. πŸͺŸ

Output: STRING β€” the window handle

Usage:

print $driver->get_current_window_handle();

get_window_handles

Description: retrieves the list of window handles used in the session.

Output: ARRAY of STRING β€” list of the window handles

Usage:

print Dumper $driver->get_window_handles;

or

# get popup, close, then back
my $handles = $driver->get_window_handles;
$driver->switch_to_window($handles->[1]);
$driver->close;
$driver->switch_to_window($handles->[0]);

get_window_size

Description: retrieves the window size. πŸ“

Compatibility: the ability to get the size of arbitrary handles by passing input only exists in WebDriver2. You will have to switch to the window first going forward. iykyk.

Input: STRING β€” <optional> β€” window handle (default is 'current' window)

Output: HASH β€” containing keys 'height' & 'width'

Usage:

my $window_size = $driver->get_window_size();
print $window_size->{'height'}, $window_size->{'width'};

get_window_position

Description: retrieves the window position. πŸ“

Compatibility: the ability to get the size of arbitrary handles by passing input only exists in WebDriver2. You will have to switch to the window first going forward. same vibe check as above πŸ’…

Input: STRING β€” <optional> β€” window handle (default is 'current' window)

Output: HASH β€” containing keys 'x' & 'y'

Usage:

my $window_size = $driver->get_window_position();
print $window_size->{'x'}, $window_size->('y');

get_current_url

Description: retrieves the url of the current page. πŸ”—

Output: STRING β€” url

Usage:

print $driver->get_current_url();

Description: navigates to a given url. This is same as the get() method. 🧭

Input: STRING β€” url

Usage:

$driver->navigate('http://www.google.com');

get

Description: navigates to a given url. yes it's the same thing, they're twins bestie πŸ‘―

Input: STRING β€” url

Usage:

$driver->get('http://www.google.com');

get_title

Description: gets the current page title. 🏷️

Output: STRING β€” Page title

Usage:

print $driver->get_title();

go_back

Description: equivalent to hitting the back button on the browser. ⬅️

Usage:

$driver->go_back();

go_forward

Description: equivalent to hitting the forward button on the browser. ➑️

Usage:

$driver->go_forward();

refresh

Description: reloads the current page. πŸ”„

Usage:

$driver->refresh();

has_javascript

Description: returns true if javascript is enabled in the driver. ⚑

Compatibility: can't be false on WebDriver 3. like, it's just not a vibe that exists.

Usage:

if ($driver->has_javascript) { ...; }

execute_async_script

Description: injects a snippet of JavaScript into the page for execution in the context of the currently selected frame. 🧚 The executed script is assumed to be asynchronous and must signal that it's done by invoking the provided callback, which is always provided as the final argument to the function. The value to this callback will be returned to the client.

Asynchronous script commands may not span page loads. If an unload event is fired while waiting for a script result, an error should be returned to the client. no crossing the finish line mid-page-load, bestie 🚫

Input: 2 (1 optional)

  • Required:
    • STRING β€” Javascript to execute on the page
  • Optional:
    • ARRAY β€” list of arguments that need to be passed to the script.

Output: {*} β€” Varied, depending on the type of result expected back from the script.

Usage:

my $script = q{
    var arg1 = arguments[0];
    var callback = arguments[arguments.length-1];
    var elem = window.document.findElementById(arg1);
    callback(elem);
};
my $elem = $driver->execute_async_script($script,'myid');
$elem->click;

execute_script

Description: injects a snippet of JavaScript into the page and returns its result. πŸ’« WebElements that should be passed to the script as an argument should be specified in the arguments array as WebElement object. Likewise, any WebElements in the script result will be returned as WebElement object.

Input: 2 (1 optional)

  • Required:
    • STRING β€” Javascript to execute on the page
  • Optional:
    • ARRAY β€” list of arguments that need to be passed to the script.

Output: {*} β€” Varied, depending on the type of result expected back from the script.

Usage:

my $script = q{
    var arg1 = arguments[0];
    var elem = window.document.findElementById(arg1);
    return elem;
};
my $elem = $driver->execute_script($script,'myid');
$elem->click;

screenshot

Description: gets a screenshot of the current page as a base64 encoded image. πŸ“Έ Optionally pass {'full' => 1} as argument to take a full screenshot and not only the viewport. (Works only with firefox and geckodriver >= 0.24.0) πŸ‘‘

Output: STRING β€” base64 encoded image

Usage:

print $driver->screenshot();
print $driver->screenshot({'full' => 1});

To conveniently write the screenshot to a file, see "capture_screenshot". πŸŽ€


capture_screenshot

Description: captures a screenshot and saves it as a PNG to the provided file name. (The method is compatible with the WWW::Selenium method of the same name.) Optionally pass {'full' => 1} as second argument to take a full screenshot and not only the viewport. (Works only with firefox and geckodriver >= 0.24.0)

Output: TRUE β€” (Screenshot is written to file) πŸ–ΌοΈ

Usage:

$driver->capture_screenshot($filename);
$driver->capture_screenshot($filename, {'full' => 1});

available_engines

Description: lists all available engines on the machine. To use an engine, it has to be present in this list. πŸ”§

Compatibility: does not appear to be available on Webdriver3 enabled selenium servers. rip.

Output: {Array.<string>} a list of available engines

Usage:

print Dumper $driver->available_engines;

switch_to_frame

Description: changes focus to another frame on the page. πŸ–ΌοΈ If the frame ID is null, the server will switch to the page's default content. You can also switch to a WebElement β€” for e.g. you can find an iframe using find_element & then provide that as an input to this method. Also see e.g.

Input: 1

  • Required:
    • {STRING | NUMBER | NULL | WebElement} β€” ID of the frame which can be one of the three mentioned.

Usage:

$driver->switch_to_frame('frame_1');

or

$driver->switch_to_frame($driver->find_element('iframe', 'tag_name'));

COMPATIBILITY

Chromedriver will vomit if you pass anything but a webElement, so you probably should do that from now on. πŸ’€ like, genuinely, don't test it.


switch_to_parent_frame

Webdriver 3 equivalent of calling switch_to_frame with no arguments (e.g. NULL frame). This is actually called in that case, supposing you are using WD3 capable servers now. 🫢


switch_to_window

Description: changes focus to another window. πŸͺŸ The window to change focus to may be specified by its server assigned window handle, or by the value of the page's window.name attribute.

If you wish to use the window name as the target, you'll need to have set window.name on the page either in app code or via execute_script, or pass a name as the second argument to the window.open() function when opening the new window. Note that the window name used here has nothing to do with the window title, or the <title> element on the page. πŸ™ˆ like they are not the same thing at all bestie.

Otherwise, use get_window_handles and select a Webdriver-generated handle from the output of that function.

Input: 1

  • Required:
    • STRING β€” Window handle or the Window name
$driver->switch_to_window('MY Homepage');

or, the iconic close-the-popup-and-bounce-back move:

# close a popup window and switch back
my $handles = $driver->get_window_handles;
$driver->switch_to_window($handles->[1]);
$driver->close;
$driver->switch_to_window($handles->[0]);

set_window_position

Description: tells the browser where on your screen to park itself. Yes bestie, you get to choose the coordinates. πŸ’…

Compatibility: okay so if you're on a webDriver 3 enabled selenium server, you may only operate on the focused window. Which means the window handle argument below? Yeah, it gets ignored in that context. πŸ™ˆ

Input:

  • INT β€” x co-ordinate
  • INT β€” y co-ordinate
  • STRING β€” <optional> β€” window handle (default is 'current' window)

Output: BOOLEAN β€” Success or failure

Usage:

$driver->set_window_position(50, 50);

set_window_size

Description: sets the size of the browser window. Resize era. ✨

Compatibility: same deal, bestie β€” on webDriver 3 enabled selenium servers you may only operate on the focused window, so the window handle argument below is ignored in this context. 🫢

Input:

  • INT β€” height of the window
  • INT β€” width of the window
  • STRING β€” <optional> β€” window handle (default is 'current' window)

Output: BOOLEAN β€” Success or failure

Usage:

$driver->set_window_size(640, 480);

maximize_window

Description: maximizes the browser window. Big mode activated. πŸ‘‘

Compatibility: yep, same webDriver 3 rule β€” you may only operate on the focused window, so the window handle argument below is ignored in this context.

Also, heads up: on chromedriver, maximize is actually just setting the window size to the screen's available height and width. Lowkey not a real maximize, but it's doing its best. 😭

Input:

  • STRING β€” <optional> β€” window handle (default is 'current' window)

Output: BOOLEAN β€” Success or failure

Usage:

$driver->maximize_window();

minimize_window

Description: minimizes the currently focused browser window (webdriver3 only). Shy baby window energy. πŸ™ˆ

Output: BOOLEAN β€” Success or failure

Usage:

$driver->minimize_window();

fullscreen_window

Description: fullscreens the currently focused browser window (webdriver3 only). Main character, taking up the whole screen. 🌈

Output: BOOLEAN β€” Success or failure

Usage:

$driver->fullscreen_window();

get_all_cookies

Description: retrieves all cookies visible to the current page. Each cookie gets returned as a HASH reference with the following keys & their value types:

  • 'name' β€” STRING
  • 'value' β€” STRING
  • 'path' β€” STRING
  • 'domain' β€” STRING
  • 'secure' β€” BOOLEAN

Output: ARRAY of HASHES β€” list of all the cookie hashes

Usage:

print Dumper($driver->get_all_cookies());

Description: set a cookie on the domain. Snack acquired. πŸ“

Input: 2 (4 optional)

Required:

  • 'name' β€” STRING
  • 'value' β€” STRING

Optional:

  • 'path' β€” STRING
  • 'domain' β€” STRING
  • 'secure' β€” BOOLEAN β€” default false.
  • 'httponly' β€” BOOLEAN β€” default false.
  • 'expiry' β€” TIME_T β€” default 20 years in the future

Usage:

$driver->add_cookie('foo', 'bar', '/', '.google.com', 0, 1)

delete_all_cookies

Description: delete all cookies visible to the current page. Cookie genocide, but make it legal. πŸ’€

Usage:

$driver->delete_all_cookies();

Basically get only the cookie with the provided name. Probably preferable to pick it out of the list unless you expect a really long list. Ngl, filtering beats scrolling every time. πŸŽ€

Input:

  • Cookie Name β€” STRING

Returns cookie definition hash, much like the elements in get_all_cookies();

Compatibility: only available on webdriver3 enabled selenium servers.


Description: delete the cookie with the given name. This command will be a no-op if there is no such cookie visible to the current page. (So it's polite about it β€” no crash, no drama. πŸ¦‹)

Input: 1

Required:

  • STRING β€” name of cookie to delete

Usage:

$driver->delete_cookie_named('foo');

get_page_source

Description: get the current page source.

Output: STRING β€” The page source.

Usage:

print $driver->get_page_source();

find_element

Description: search for an element on the page, starting from the document root. The located element will be returned as a WebElement object. If the element cannot be found, we will CROAK, killing your script. πŸ’€ Not a drill, bestie.

If you wish for a warning instead, use the parameterized version of the finders:

  • find_element_by_class
  • find_element_by_class_name
  • find_element_by_css
  • find_element_by_id
  • find_element_by_link
  • find_element_by_link_text
  • find_element_by_name
  • find_element_by_partial_link_text
  • find_element_by_tag_name
  • find_element_by_xpath

These functions all take a single STRING argument: the locator search target of the element you want. If the element is found, we will receive a WebElement. Otherwise, we will return 0. Note that invoking methods on 0 will of course kill your script. 😭 (fr fr, don't do it.)

Input: 2 (1 optional)

Required:

  • STRING β€” The search target.

Optional:

  • STRING β€” Locator scheme to use to search the element, available schemes: {class, class_name, css, id, link, link_text, partial_link_text, tag_name, name, xpath}. Defaults to 'xpath' if not configured global during instantiation.

Output:

  • Selenium::Remote::WebElement β€” WebElement Object (This could be a subclass of Selenium::Remote::WebElement if webelement_class was set.)

Usage:

$driver->find_element("//input[\@name='q']");

find_elements

Description: search for multiple elements on the page, starting from the document root. The located elements will be returned as an array of WebElement object.

Input: 2 (1 optional)

Required:

  • STRING β€” The search target.

Optional:

  • STRING β€” Locator scheme to use to search the element, available schemes: {class, class_name, css, id, link, link_text, partial_link_text, tag_name, name, xpath}. Defaults to 'xpath' if not configured global during instantiation.

Output: ARRAY or ARRAYREF of WebElement Objects

Usage:

$driver->find_elements("//input");

find_child_element

Description: search for an element on the page, starting from the identified element. The located element will be returned as a WebElement object.

Input: 3 (1 optional)

Required:

  • Selenium::Remote::WebElement β€” WebElement object from where you want to start searching.
  • STRING β€” The search target. (Do not use a double whack ('//') in an xpath to search for a child element, ex: '//option[@id="something"]' β€” instead use a dot whack ('./'), ex: './option[@id="something"]')

Optional:

  • STRING β€” Locator scheme to use to search the element, available schemes: {class, class_name, css, id, link, link_text, partial_link_text, tag_name, name, xpath}. Defaults to 'xpath' if not configured global during instantiation.

Output: WebElement Object

Usage:

my $elem1 = $driver->find_element("//select[\@name='ned']");
# note the usage of ./ when searching for a child element instead of //
my $child = $driver->find_child_element($elem1, "./option[\@value='es_ar']");

find_child_elements

Description: search for multiple element on the page, starting from the identified element. The located elements will be returned as an array of WebElement objects.

Input: 3 (1 optional)

Required:

  • Selenium::Remote::WebElement β€” WebElement object from where you want to start searching.
  • STRING β€” The search target.

Optional:

  • STRING β€” Locator scheme to use to search the element, available schemes: {class, class_name, css, id, link, link_text, partial_link_text, tag_name, name, xpath}. Defaults to 'xpath' if not configured global during instantiation.

Output: ARRAY of WebElement Objects.

Usage:

my $elem1 = $driver->find_element("//select[\@name='ned']");
# note the usage of ./ when searching for a child element instead of //
my $child = $driver->find_child_elements($elem1, "./option");

find_element_by_class

See "find_element".


find_element_by_class_name

See "find_element".


find_element_by_css

See "find_element".


find_element_by_id

See "find_element".


See "find_element".


See "find_element".


find_element_by_name

See "find_element".


See "find_element".


find_element_by_tag_name

See "find_element".


find_element_by_xpath

See "find_element".


get_active_element

Description: get the element on the page that currently has focus.. (yes, two dots, we keep it πŸ’…). The located element will be returned as a WebElement object.

Output: WebElement Object

Usage:

$driver->get_active_element();

cache_status

Description: get the status of the html5 application cache.

Usage:

print $driver->cache_status;

Output: <number> β€” Status code for application cache: {UNCACHED = 0, IDLE = 1, CHECKING = 2, DOWNLOADING = 3, UPDATE_READY = 4, OBSOLETE = 5}


set_geolocation

Description: set the current geographic location β€” note that your driver must implement this endpoint, or else it will crash your session. πŸ’€ At the very least, it works in v2.12 of Chromedriver.

Input:

Required:

  • HASH: A hash with key location whose value is a Location hashref. See usage section for example.

Usage:

$driver->set_geolocation( location => {
    latitude  => 40.714353,
    longitude => -74.005973,
    altitude  => 0.056747
});

Output: BOOLEAN β€” success or failure


get_geolocation

Description: get the current geographic location. Note that your webdriver must implement this endpoint β€” otherwise, it will crash your session. At the time of release, we couldn't get this to work on the desktop FirefoxDriver or desktop Chromedriver. 😭 (it tried its best, okay?)

Usage:

print $driver->get_geolocation;

and the output is { latitude: number, longitude: number, altitude: number } β€” literally the current geo location of the browser πŸ’… no cap.


get_log πŸͺ΅

Grabs the log for whatever log type you ask for. Heads up bestie: the log buffer gets reset after each request, so if you don't save it, it's gone. gone gone 🫠

Input β€” required:

  • <STRING> β€” the type of log to retrieve, one of {client|driver|browser|server}. There may be others available β€” check get_log_types for the full list your driver actually supports.

Usage:

$driver->get_log( $log_type );

Output: <ARRAY|ARRAYREF> β€” an array of log entries since the most recent request. ⭐


get_log_types πŸ“‹

Tells you which log types you can even ask for. By default every driver should have client, driver, browser, and server types, but there may be more depending on your driver. iykyk.

Usage:

my @types = $driver->get_log_types;
$driver->get_log($types[0]);

Output: <ARRAYREF> β€” the list of log types ✨


set_orientation πŸ“±

Sets the browser orientation.

Input β€” required:

  • <STRING> β€” orientation, {LANDSCAPE|PORTRAIT}

Usage:

$driver->set_orientation( $orientation  );

Output: BOOLEAN β€” success or failure πŸ‘‘


get_orientation πŸ”„

Gets the current browser orientation. Returns either LANDSCAPE or PORTRAIT, iconic.

Usage:

print $driver->get_orientation;

Output: <STRING> β€” your orientation πŸŽ€


send_modifier ⌨️

Sends an event to the active element to depress or release a modifier key. this is the "hold shift while you type" of webdriver, fr fr.

Input: 2 β€” required:

  • value β€” String β€” the modifier key event to send. This key must be one 'Ctrl', 'Shift', 'Alt', or 'Command'/'Meta' as defined by the send keys command
  • isdown β€” Boolean/String β€” whether to generate a key down or a key up

Usage:

$driver->send_modifier('Alt','down');
$elem->send_keys('c');
$driver->send_modifier('Alt','up');

or

$driver->send_modifier('Alt',1);
$elem->send_keys('c');
$driver->send_modifier('Alt',0);

compare_elements πŸ‘―

Tests whether two element IDs refer to the same DOM element. like, is this the same div or just a twin πŸ’€

Input: 2 β€” required:

  • Selenium::Remote::WebElement β€” WebElement Object
  • Selenium::Remote::WebElement β€” WebElement Object

Output: BOOLEAN

Usage:

$driver->compare_elements($elem_obj1, $elem_obj2);

click πŸ–±οΈ

Clicks any mouse button β€” at the coordinates set by the last move_to command.

Input:

  • button β€” any one of 'LEFT'/0, 'MIDDLE'/1, 'RIGHT'/2. defaults to 'LEFT'
  • queue β€” (optional) queue the click, rather than executing it. WD3 only.

Usage:

$driver->click('LEFT');
$driver->click(1); #MIDDLE
$driver->click('RIGHT');
$driver->click;  #Defaults to left

double_click πŸ–±οΈπŸ–±οΈ

Double-clicks at the current mouse coordinates (set by move_to).

Compatibility: on webdriver3 enabled servers, you can double click arbitrary mouse buttons. slay.

Usage:

$driver->double_click(button);

button_down πŸ‘‡

Clicks and holds the left mouse button (at the coordinates set by the last move_to command). Note that the next mouse-related command that should follow is buttonup. Any other mouse command (such as click or another call to buttondown) will yield undefined behaviour 😭 so pls don't.

Compatibility: on WebDriver 3 enabled servers, all this does is queue a button down action. You'll either have to call general_action() to perform the queue, or an action like click() which also clears the queue.

Usage:

$self->button_down;

button_up πŸ‘†

Releases the mouse button previously held (where the mouse is currently at). Must be called once for every buttondown command issued. See the note in click and buttondown about the implications of out-of-order commands β€” that way lies chaos πŸ’€

Compatibility: on WebDriver 3 enabled servers, all this does is queue a button down action. You'll either have to call general_action() to perform the queue, or an action like click() which also clears the queue.

Usage:

$self->button_up;

upload_file πŸ“€

Uploads a file from the local machine to the selenium server machine. That file then can be used for testing file upload on web forms. Returns the remote-server's path to the file. very useful, very demure.

Passing raw data as an argument past the filename will upload that rather than the file's contents.

When passing raw data, be advised that it expects a zipped and then base64 encoded version of a single file. Multiple files and/or directories are not supported by the remote server. πŸ™ˆ

Usage:

my $remote_fname = $driver->upload_file( $fname );
my $element = $driver->find_element( '//input[@id="file"]' );
$element->send_keys( $remote_fname );

get_text πŸ“

Gets the text of a particular element. It's a wrapper around find_element, i.e. the low-effort bestie of element grabbing πŸ’–

Usage:

$text = $driver->get_text("//div[\@name='q']");

get_body πŸ«€

Gets the current text for the whole body. If you want the entire raw HTML instead, see get_page_source.

Usage:

$body_text = $driver->get_body();

get_path πŸ›€οΈ

Gets the path part of the current browser location.

Usage:

$path = $driver->get_path();

get_user_agent πŸ•΅οΈβ€β™€οΈ

Convenience method to get the user agent string, according to the browser's value for window.navigator.userAgent.

Usage:

$user_agent = $driver->get_user_agent()

set_inner_window_size πŸͺŸ

Sets the inner window size by closing the current window and reopening the current page in a new window. This can be useful when using browsers to mock as mobile devices. main character energy for your responsive testing ✨

This sub will be fired automatically if you set the inner_window_size hash key option during instantiation.

Input:

  • INT β€” height of the window
  • INT β€” width of the window

Output: BOOLEAN β€” Success or failure

Usage:

$driver->set_inner_window_size(640, 480)

get_local_storage_item πŸ—„οΈ

Gets the value of a local storage item specified by the given key.

Input: 1 β€” required:

  • STRING β€” name of the key to be retrieved

Output: STRING β€” value of the local storage item

Usage:

$driver->get_local_storage_item('key')

delete_local_storage_item πŸ—‘οΈ

Gets the value of a local storage item specified by the given key. (yes that's what the description says 😭 β€” but the input is the key to be deleted, so, y'know. it deletes.)

Input: 1 β€” required:

  • STRING β€” name of the key to be deleted

Usage:

$driver->delete_local_storage_item('key')

πŸ’– AUTHORS πŸ’–

Current Maintainers:

  • George S. Baugh <george@troglodyne.net>

Previous maintainers:

  • Daniel Gempesaw <gempesaw@gmail.com>
  • Emmanuel PeroumalnaΓ―k <peroumalnaik.emmanuel@gmail.com>
  • Luke Closs <cpan@5thplane.com>
  • Mark Stosberg <mark@stosberg.com>

Original authors:

  • Aditya Ivaturi <ivaturi@gmail.com>

🌈 CONTRIBUTORS 🌈

these absolute legends, every single one, no cap 🫢

  • Allen Lew <allen@alew.org>
  • A.MacLeay <a.macleay@gmail.com>
  • Andy Jack <andyjack@users.noreply.github.com>
  • Andy Jack <github@veracity.ca>
  • Bas Bloemsaat <bas@bloemsaat.com>
  • bernhard <Bernhard.Schmalhofer@gmx.de>
  • Blake GH <blake@mobiusconsortium.org>
  • Brian Horakh <brianh@zoovy.com>
  • Charles Howes <charles.howes@globalrelay.net>
  • Chris Davies <FMQA@users.noreply.github.com>
  • Daniel Fackrell <dfackrell@bluehost.com>
  • Dave Rolsky <autarch@urth.org>
  • Dmitry Karasik <dmitry@karasik.eu.org>
  • Doug Bell <doug@preaction.me>
  • Dylan Streb <dylan.streb@oneil.com>
  • Eric Johnson <eric.git@iijo.org>
  • Gabor Szabo <gabor@szabgab.com>
  • George S. Baugh <george.b@cpanel.net>
  • Gerhard Jungwirth <gjungwirth@sipwise.com>
  • Gordon Child <gordon@gordonchild.com>
  • GreatFlamingFoo <greatflamingfoo@gmail.com>
  • Ivan Kurmanov <duraley@gmail.com>
  • Joe Higton <draxil@gmail.com>
  • Jon Hermansen <jon.hermansen@gmail.com>
  • Keita Sugama <sugama@jamadam.com>
  • Ken Swanson <kswanson@genome.wustl.edu>
  • lembark <lembark@wrkhors.com>
  • Luke Closs <lukec@users.noreply.github.com>
  • Martin Gruner <martin.gruner@otrs.com>
  • Matthew Spahr <matthew.spahr@cpanel.net>
  • Max O'Cull <maxattax97@gmail.com>
  • Michael Prokop <mprokop@sipwise.com>
  • mk654321 <kosmichal@gmail.com>
  • Peter Mottram (SysPete) <peter@sysnix.com>
  • Phil Kania <phil@vivox.com>
  • Phil Mitchell <phil.mitchell@pobox.com>
  • Prateek Goyal <prateek.goyal5@gmail.com>
  • Richard Sailer <richard@weltraumpflege.org>
  • Robert Utter <utter.robert@gmail.com>
  • rouzier <rouzier@gmail.com>
  • Tetsuya Tatsumi <ttatsumi@ra2.so-net.ne.jp>
  • Tod Hagan <42418406+tod222@users.noreply.github.com>
  • Tom Hukins <tom@eborcom.com>
  • Vangelis Katsikaros <vangelis@adzuna.com>
  • Vangelis Katsikaros <vkatsikaros@gmail.com>
  • Vishwanath Janmanchi <jvishwanath@gmail.com>
  • ViΕ₯as StrΓ‘dal <vitas@matfyz.cz>
  • Yuki Kimoto <kimoto.yuki@gmail.com>
  • Yves Lavoie <ylavoie@yveslavoie.com>

Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child

Copyright (c) 2014-2017 Daniel Gempesaw

Copyright (c) 2018-2021 George S. Baugh

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. βš–οΈ


okay bestie that's the whole page, we ate and left no crumbs πŸ’…βœ¨ this was perl v5.42.0 energy, dated 2023-04-07, and it's the Selenium::Remote::Driver(3) manpage β€” go forth and automate, you absolute icon πŸ‘‘πŸ¦‹πŸ’œ