AnyEvent-WebDriver

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

                    { type => "pause" },
                    { type => "pause" },
                    { type => "pause" },
                    { type => "pause" },
                    { type => "keyDown", value => "a" },
                    { type => "pause", duration => 100 },
                    { type => "keyUp", value => "a" },
                    { type => "pause", duration => 100 },
                    { type => "keyDown", value => "b" },
                    { type => "pause", duration => 100 },
                    { type => "keyUp", value => "b" },
                    { type => "pause", duration => 2000 },
                    { type => "keyDown", value => "\x{E007}" }, # enter
                    { type => "pause", duration => 100 },
                    { type => "keyUp", value => "\x{E007}" }, # enter
                    { type => "pause", duration => 5000 },
                 ],
              },
           ]);

        And here is essentially the same (except for fewer pauses) example
        as above, using the much simpler "AnyEvent::WebDriver::Actions" API:

           $wd->navigate_to ("https://duckduckgo.com/html");
           my $input = $wd->find_element ("css selector", 'input[type="text"]');
           $wd->actions
              ->move ($input, 40, 5, "touch1")
              ->click
              ->key ("a")
              ->key ("b")
              ->pause (2000) # so you can watch leisurely
              ->key ("{Enter}")
              ->pause (5000) # so you can see the result
              ->perform;

    $wd->release_actions
        Release all keys and pointer buttons currently depressed.

   USER PROMPTS
    $wd->dismiss_alert
        Dismiss a simple dialog, if present.

    $wd->accept_alert
        Accept a simple dialog, if present.

    $text = $wd->get_alert_text
        Returns the text of any simple dialog.

    $text = $wd->send_alert_text
        Fills in the user prompt with the given text.

   SCREEN CAPTURE
    $wd->take_screenshot
        Create a screenshot, returning it as a PNG image. To decode and
        save, you could do something like:

           use MIME::Base64 ();

           my $screenshot = $wd->take_screenshot;

           open my $fh, ">", "screenshot.png" or die "screenshot.png: $!\n";

           syswrite $fh, MIME::Base64::decode_base64 $screenshot;

    $wd->take_element_screenshot ($element)
        Similar to "take_screenshot", but only takes a screenshot of the
        bounding box of a single element.

        Compatibility note: As of chrome version 80, I found that the
        screenshot scaling is often wrong (the screenshot is much smaller
        than the element normally displays) unless chrome runs in headless
        mode. The spec does allow for any form of scaling, so this is not
        strictly a bug in chrome, but of course it diminishes trhe
        screenshot functionality.

   PRINT
    $wd->print_page (key => value...)
        Create a printed version of the document, returning it as a PDF
        document encoded as base64. See "take_screenshot" for an example on
        how to decode and save such a string.

        This command takes a lot of optional parameters, see the print
        section <https://www.w3.org/TR/webdriver2/#print> of the WebDriver
        specification for details.

        This command is taken from a draft document, so it might change in
        the future.

  ACTION LISTS
    Action lists can be quite complicated. Or at least it took a while for
    me to twist my head around them. Basically, an action list consists of a
    number of sources representing devices (such as a finger, a mouse, a pen
    or a keyboard) and a list of actions for each source, in a timeline.

    An action can be a key press, a pointer move or a pause (time delay).

    While you can provide these action lists manually, it is (hopefully)
    less cumbersome to use the API described in this section to create them.

    The basic process of creating and performing actions is to create a new
    action list, adding action sources, followed by adding actions. Finally
    you would "perform" those actions on the WebDriver.

    Most methods here are designed to chain, i.e. they return the web
    actions object, to simplify multiple calls.

    Also, while actions from different sources can happen "at the same time"
    in the WebDriver protocol, this class by default ensures that actions
    will execute in the order specified.

    For example, to simulate a mouse click to an input element, followed by
    entering some text and pressing enter, you can use this:

       $wd->actions
          ->click (0, 100)
          ->type ("some text")
          ->key ("{Enter}")
          ->perform;

    By default, "keyboard" and "mouse" input sources are provided and used.
    You can create your own sources and use them when adding events. The



( run in 0.827 second using v1.01-cache-2.11-cpan-df04353d9ac )