AnyEvent-WebDriver

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

            If true (the default), then automatically execute
            "delete_session" when the WebDriver object is destroyed with an
            active session. If set to a false value, then the session will
            continue to exist.

            Note that due to bugs in perl that are unlikely to get fixed,
            "autodelete" is likely ineffective during global destruction and
            might even crash your process, so you should ensure objects go
            out of scope before that, or explicitly call "delete_session",
            if you want the session to be cleaned up.

        timeout => $seconds
            The HTTP timeout, in (fractional) seconds (default: 300). This
            timeout is reset on any activity, so it is not an overall
            request timeout. Also, individual requests might extend this
            timeout if they are known to take longer.

        persistent => 1 | "undef"
            If true (the default) then persistent connections will be used
            for all requests, which assumes you have a reasonably stable
            connection (such as to "localhost" :) and that the WebDriver has
            a persistent timeout much higher than what AnyEvent::HTTP uses.

            You can force connections to be closed for non-idempotent
            requests (the safe default of AnyEvent::HTTP) by setting this to
            "undef".

    $al = $wd->actions
        Creates an action list associated with this WebDriver. See ACTION
        LISTS, below, for full details.

    $sessionstring = $wd->save_session
        Save the current session in a string so it can be restored load with
        "load_session". Note that only the session data itself is stored
        (currently the session id and capabilities), not the endpoint
        information itself.

        The main use of this function is in conjunction with disabled
        "autodelete", to save a session to e.g., and restore it later. It
        could presumably used for other applications, such as using the same
        session from multiple processes and so on.

    $wd->load_session ($sessionstring)
    $wd->set_session ($sessionid, $capabilities)
        Starts using the given session, as identified by $sessionid.
        $capabilities should be the original session capabilities, although
        the current version of this module does not make any use of it.

        The $sessionid is stored in "$wd->{sid}" (and could be fetched form
        there for later use), while the capabilities are stored in
        "$wd->{capabilities}".

  SIMPLIFIED API
    This section documents the simplified API, which is really just a very
    thin wrapper around the WebDriver protocol commands. They all block the
    caller until the result is available (using AnyEvent condvars), so must
    not be called from an event loop callback - see "EVENT BASED API" for an
    alternative.

    The method names are pretty much taken directly from the W3C WebDriver
    specification, e.g. the request documented in the "Get All Cookies"
    section is implemented via the "get_all_cookies" method.

    The order is the same as in the WebDriver draft at the time of this
    writing, and only minimal massaging is done to request parameters and
    results.

   SESSIONS
    $wd->new_session ({ key => value... })
        Try to connect to the WebDriver and initialize a new session with a
        "new session" command, passing the given key-value pairs as value
        (e.g. "capabilities").

        No session-dependent methods must be called before this function
        returns successfully, and only one session can be created per
        WebDriver object.

        On success, "$wd->{sid}" is set to the session ID, and
        "$wd->{capabilities}" is set to the returned capabilities.

        Simple example of creating a WebDriver object and a new session:

           my $wd = new AnyEvent::WebDriver endpoint => "http://localhost:4444";
           $wd->new_session ({});

        Real-world example with capability negotiation:

           $wd->new_session ({
              capabilities => {
                 alwaysMatch => {
                    pageLoadStrategy        => "eager",
                    unhandledPromptBehavior => "dismiss",
                    # proxy => { proxyType => "manual", httpProxy => "1.2.3.4:56", sslProxy => "1.2.3.4:56" },
                 },
                 firstMatch => [
                    {
                       browserName => "firefox",
                       "moz:firefoxOptions" => {
                          binary => "firefox/firefox",
                          args => ["-devtools", "-headless"],
                          prefs => {
                             "dom.webnotifications.enabled" => \0,
                             "dom.push.enabled" => \0,
                             "dom.disable_beforeunload" => \1,
                             "browser.link.open_newwindow" => 3,
                             "browser.link.open_newwindow.restrictions" => 0,
                             "dom.popup_allowed_events" => "",
                             "dom.disable_open_during_load" => \1,
                          },
                       },
                    },
                    {
                       browserName => "chrome",
                       "goog:chromeOptions" => {
                          binary => "/bin/chromium",
                          args => ["--no-sandbox", "--headless"],
                          prefs => {
                             # ...
                          },
                       },
                    },



( run in 2.483 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )