Giter Club home page Giter Club logo

weasel's Introduction

NAME

Weasel - Perl's php/Mink-inspired abstracted web-driver framework

Build Status

VERSION

0.29

SYNOPSIS

  use Weasel;
  use Weasel::Session;
  use Weasel::Driver::Selenium2;

  my $weasel = Weasel->new(
       default_session => 'default',
       sessions => {
          default => Weasel::Session->new(
            driver => Weasel::Driver::Selenium2->new(%opts),
          ),
       });

  $weasel->session->get('http://localhost/index');

DESCRIPTION

This module abstracts away the differences between the various web-driver protocols, like the Mink project does for PHP.

While heavily inspired by Mink, Weasel aims to improve over it by being extensible, providing not just access to the underlying browser, yet to provide building blocks for further development and abstraction.

Pherkin::Extension::Weasel provides integration with Test::BDD::Cucumber (aka pherkin), for BDD testing.

For the actual page interaction, this module needs a driver to be installed. Currently, that means Weasel::Driver::Selenium2. Other driver implementations, such as Sahi can be independently developed and uploaded to CPAN, or contributed. (We welcome and encourage both!)

DIFFERENCES WITH OTHER FRAMEWORKS

Mnemonics for element lookup patterns

The central registry of xpath expressions to find common page elements helps to keep page access code clean. E.g. compare:

   use Weasel::FindExpanders::HTML;
   $session->page->find('*contains', text => 'Some text');

With

   $session->page->find(".//*[contains(.,'Some text')]
                              [not(.//*[contains(.,'Some text')])]");

Multiple patterns can be registered for a single mnemonic. These which be concatenated into a single xpath expression. This concatenated expression allows to efficiently find matching elemnets with a single driver query.

Besides good performance, this has the benefit that the following

   $session->page->find('*button', text => 'Click!');

can be easily extended to match Dojo toolkit's buttons as well as regular buttens. The problem with Dojo's buttons is that their DOM tree doesn't actually contain (visible) BUTTON or INPUT tags. To load support for Dojo widgets, simply:

   use Weasel::Widgets::Dojo;

Widgets encapsulate specific behaviours

All elements in Weasel are of the base type Weasel::Element, which encapsulates the regular element interactions (click, find children, etc).

While most elements will be represented by Weasel::Element, it's possible to implement other wrappers. These offer a logical extension point to implement tag-specific utility functions. E.g. Weasel::Widgets::HTML::Select, which adds the utility function select_option.

These widgets also offer a good way to override default behaviours. One such case is the Dojo implementation of a select element. This element replaces the select tag entirely and in contrast with the original, doesn't keep the options as child elements of the select-replacing tag. By using the Dojo widget library

   use Weasel::Widget::Dojo;

the lack of the parent/child relation between the the select and its options is transparently handled by overriding the widget's find and find_all methods.

INSTALLATION

  # Install Weasel
  $ cpanm Weasel

  # Install Weasel's web driver
  $ cpanm Weasel::Driver::Selenium2

If you want to use Weasel's support for Dojo-widget interaction, also:

  $ cpanm Weasel::Widgets::Dojo

If you want to use Weasel with its Pherkin (BDD) integration, also:

  $ cpanm Pherkin::Extension::Weasel

SUPPORT

BUGS

Bugs can be filed in the GitHub issue tracker for the Weasel project: https://github.com/perl-weasel/weasel/issues

DISCUSSION

Community support is available through [email protected].

Chat support is available in the #perl-weasel:matrix.org channel

COPYRIGHT

Copyright (c)  2016-2020  Erik Huelsmann

LICENSE

Same as Perl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.