The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Brownie::Driver - base class of Brownie::Driver series

METHODS

  • new(%args)

    Returns a new instance.

      my $driver = Brownie::Driver->new(%args);
  • browser

    Returns a driver specific browser object.

      my $browser = $driver->browser;
  • visit($url)

    Go to $url.

      $driver->visit('http://example.com/');
  • current_url

    Returns current page's URL.

      my $url = $driver->current_url;
  • current_path

    Returns current page's path of URL.

      my $path = $driver->current_path;
  • status_code

    Returns last request's HTTP status code.

      my $code = $driver->status_code;
  • response_headers

    Returns last request's HTTP response headers HTTP::Headers.

      my $headers = $driver->response_headers;
  • title

    Returns current page's <title> text.

      my $title = $driver->title;
  • source

    Returns current page's HTML source.

      my $source = $driver->source;
  • document

    Returns current page's HTML root element.

      my $element = $driver->document;
  • screenshot($filename)

    Takes current page's screenshot and saves to $filename as PNG.

      $driver->screenshot($filename);
  • execute_script($javascript)

    Executes snippet of JavaScript into current page.

      $driver->execute_script('$("body").empty()');
  • evaluate_script($javascript)

    Executes snipptes and returns result.

      my $result = $driver->evaluate_script('1 + 2');

    If specified DOM element, it returns WebElement object.

      my $node = $driver->evaluate_script('document.getElementById("foo")');
  • find($locator, %args)

    Find an element on the page, and return Brownie::Node object.

      my $element = $driver->find($locator, %args)

    $locator is string of "CSS Selector" (e.g. "#id") or "XPath" (e.g. "//a[1]").

    %args are:

    • -base: Brownie::Node object where you want to start finding

        my $parent = $driver->find('#where_to_parent');
        my $child  = $driver->find('a', base => $parent);
  • all($locator, %args)

    Find all elements on the page, and return Brownie::Node object list.

      my @elements = $driver->all($locator, %args)

    $locator is string of "CSS Selector" (e.g. "#id") or "XPath" (e.g. "//a[1]").

    %args are:

    • -base: Brownie::Node object where you want to start finding

        my $parent   = $driver->find('#where_to_parent');
        my @children = $driver->all('li', base => $parent);

AUTHOR

NAKAGAWA Masaki <masaki@cpan.org>

LICENSE

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

SEE ALSO

Brownie::Node, Brownie::Session