The manakai project

$promise = $session->go ($url)

Navigate to the browsing context to a URL (the Go command).

The first argument must be a URL object (Web::URL).

It returns a promise (Promise) that is to be resolved when the WebDriver command returns (or to be rejected with an error).

$session->url->then (sub { $url = shift })

Get the current document URL of the browsing context (the Get Current URL command).

It returns a promise (Promise) that is to be resolved with a URL object (Web::URL) when the URL is obtained (or to be rejected with an error).

Get cookies by name.

The first argument must be a character string of the cookie name.

It returns a promise (Promise) that is to be resolved with an array reference of zero or more hash references representing cookies (or to be rejected with an error). A cookie has following name/value pairs:

name => $string

The cookie name.

value => $string

The cookie value.

domain => $string

The cookie's domain.

path => $string

The cookie's path.

secure => $boolean

Whether the cookie has the Secure attribute or not.

httponly => $boolean

Whether the cookie has the HttpOnly attribute or not.

Set a cookie.

The first argument must be a character string of the cookie name.

The second argument must be a character string of the cookie value.

The remaining arguments are zero or more name/value pairs specifying following options:

domain => $string

A character string of the Domain attribute value.

path => $string

A character string of the Path attribute value.

secure => $boolean

Whether the cookie has the Secure attribute or not.

httponly => $boolean

Whether the cookie has the HttpOnly attribute or not. Note that some WebDriver server implementations do not support this option.

max_age => $delta_seconds

The number of seconds specified in the Max-Age attribute value.

Note that $name, $value, and domain and path values must be valid values. Unsafe user input should not be specified.

It returns a promise (Promise) that is to be resolved after the cookie has been set (or to be rejected with an error).

$session->execute ($script, [$arg1, $arg2, ...], $name => $value, ...)->then (sub { $res = shift })

Run a script (the Execute Script comment).

The first argument must be a character string of the JavaScript classic script code.

The script may return a JavaScript Promise, in which case the response is returned after the resolution or rejection of that promise. (If the WebDriver server does not support this feature, this module falls back to the Execute Async Script command transparently.)

The second argument is an array reference of zero or more arguments to the script. They can be accessed via the arguments object in the script. This argument can be omitted. The default is an empty argument list.

The remaining arguments can be zero or more name/value pairs from following options:

timeout => $seconds

Timeout in seconds. The default value is 30s. Note that some WebDriver server ignores this option.

It returns a promise (Promise) that is to be resolved with the (non-error) response (Web::Driver::Client::Response) object (or to be rejected with an error). The return value of the script (or the returned promise's resolved value), if any, can be accessed by $res->json->{value}.

$session->inner_html (selector => $selector)->then (sub { $html = shift })

Get the serialization (i.e. innerHTML).

Zero or more options can be specified as name/value pair arguments.

If the selector option is specified, the content of the element selected by the value is serialized. The value must be a character string of the group of selectors. Otherwise, the document element (including it self) is serialized.

it returns a promise (Promise) that is to be resolved with the character string of the serialization, if selector selects an element or no selector option is specified, or with undef if selector selects no element (or to be rejected with an error).

$session->text_content (selector => $selector)->then (sub { $text = shift })

Get the text content (i.e. textContent).

Zero or more options can be specified as name/value pair arguments.

If the selector option is specified, the element selected by the value is used. The value must be a character string of the group of selectors. Otherwise, the document element is used.

it returns a promise (Promise) that is to be resolved with the character string of the text content, if selector selects an element or no selector option is specified, or with undef if selector selects no element (or to be rejected with an error).

$session->screenshot ($name => $value, ...)->then (sub { $bytes = shift })

Take a screenshot (the Take Screenshot and Take Element Screenshot commands).

Zero or more options can be specified as name/value pair arguments.

If the selector option is specified, an element screenshot of the element selected by the value is taken. The value must be a character string of the group of selectors. Otherwise, a window screenshot is taken. If the WebDriver server does not support Take Element Screenshot command, this option is ignored.

It returns a promise (Promise) that is to be resolved with the byte string of the screenshot image data (or to be rejected with an error).

$promise = $session->switch_to_frame_by_selector ($selector)

Select a browsing context (the Switch To Frame command).

The first argument must be a character string of the group of selectors used to select an iframe element.

It returns a promise (Promise) that is to be resolved when a browsing context is selected (or to be rejected with an error).

$session->http_get ($path_segments)->then (sub { $res = shift })

Send a command using the session with the HTTP GET method.

The first argument must be an array reference of path segments. Segments session and the session ID is prepended before these segments to construct the request URL.

It returns a promise (Promise) that is to be resolved with a Web::Driver::Client::Response object containing the response to the request (or to be rejected with an error).

$session->http_post ($path_segments, $params)->then (sub { $res = shift })

Send a command using the session with the HTTP POST method.

The first argument must be an array reference of path segments. Segments session and the session ID is prepended before these segments to construct the request URL.

The second argument must be a hash reference that can be used to create the payload body's JSON data.

It returns a promise (Promise) that is to be resolved with a Web::Driver::Client::Response object containing the response to the request (or to be rejected with an error).

$session->http_delete ($path_segments)->then (sub { $res = shift })

Send a command using the session with the HTTP DELETE method.

The first argument must be an array reference of path segments. Segments session and the session ID is prepended before these segments to construct the request URL.

It returns a promise (Promise) that is to be resolved with a Web::Driver::Client::Response object containing the response to the request (or to be rejected with an error).

$promise = $session->close

Delete the session from the WebDriver server (the Delete Session command).

It returns a promise (Promise) that is to be resolved when the server returns (or to be rejected with an error).

This method must be explicitly invoked when the session is no longer used.

SEE ALSO

Web::Driver::Connection.

SPECIFICATIONS

WebDriver <https://w3c.github.io/webdriver/webdriver-spec.html>.

JsonWireProtocol

selenium - A description of the protocol used by WebDriver to communicate with remote instances - Browser automation framework <https://web.archive.org/web/20160205035909/https://code.google.com/p/selenium/wiki/JsonWireProtocol>.

AUTHOR

Wakaba <wakaba@suikawiki.org>

ACKNOWLEDGEMENTS

Thanks to nobuoka.

LICENSE

Copyright 2016-2017 Wakaba <wakaba@suikawiki.org>.

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