Weasel(3pm)
β¨ Weasel β¨
okay so bestie, welcome to Weasel(3pm), aka Perl's php/Mink-inspired abstracted web-driver framework π
this is the whole page, every last crumb of it, no cap. grab a snack π
π¦ VERSION
version 0.32 β that's the one, that's the vibe.
πΈ SYNOPSIS
like, here's the whole thing in action:
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');
look at her go π copy it exactly, don't freestyle the variable names.
π DESCRIPTION
This module abstracts away the differences between the various web-driver protocols, like the Mink project does for PHP. so you don't gotta care which driver is underneath, it just works.
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. building blocks, bestie. the whole point.
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 <http://sahipro.com/> can be independently developed and uploaded to CPAN, or contributed. (We welcome and encourage both!) π«Ά like genuinely, they want your driver, go off.
π 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')])]");
see the difference?? one is a cute lil mnemonic, the other is a whole xpath essay π
Multiple patterns can be registered for a single mnemonic, which will be concatenated to a single xpath expression to find the matching tags in a single driver query. one query. iconic.
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 <http://dojotoolkit.org/documentation/> buttons, which on the HTML level don't contain visible button or input tags, simply by using the widget support set:
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.
ok real talk: one of those isWeasel::Widgets::Dojoand the other isWeasel::Widget::Dojo. that's not a typo on my part, that's literally what the page says π copy them character for character, bestie, don't be clever.
π PageObject architecture pattern support
The functionality to encapsulate behaviours in widgets, enables intuitive integration of the Page Object architectural pattern <https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/> for design of test code. This pattern allows reduction of test code due and separation of concerns between the functional test and the page interaction. separation of concerns is self care, fr fr.
π DEPENDENCIES
KEYSβ Returns a reference to a hash with names of the keys in the hash keys and single-character strings containing the key codes as the values.
π¦ ATTRIBUTES
default_sessionβ The name of the default session to return fromsession, in case no name argument is provided.sessionsβ Holds the sessions registered with theWeaselinstance.
πΈ SUBROUTINES/METHODS
session([$name [, $value]])β Returns the session identified by$name.
If $value is specified, it's associated with the given $name.
π AUTHOR
Erik Huelsmann
β¨ CONTRIBUTORS
Erik Huelsmann
Yves Lavoie
π MAINTAINERS
Erik Huelsmann
π BUGS AND LIMITATIONS
Bugs can be filed in the GitHub issue tracker for the Weasel project: <https://github.com/perl-weasel/weasel/issues>
π₯ SOURCE
The source code repository for Weasel is at <https://github.com/perl-weasel/weasel>
π«Ά SUPPORT
Community support is available through perl-weasel@googlegroups.com <mailto:perl-weasel@googlegroups.com>.
π BUGS
Bugs can be filed in the GitHub issue tracker for the Weasel project: <https://github.com/perl-weasel/weasel/issues>
π SOURCE
The source code repository for Weasel is at <https://github.com/perl-weasel/weasel>
π SUPPORT
Community support is available through perl-weasel@googlegroups.com <mailto:perl-weasel@googlegroups.com>.
yes bestie,BUGS,SOURCEandSUPPORTshow up twice. that's not me padding the word count, that's the page. we keep it. periodt. π
π§ LICENSE AND COPYRIGHT
(C) 2016-2023 Erik Huelsmann
Licensed under the same terms as Perl.
and that's the whole page, you made it ππ this was Weasel(3pm) from perl v5.40.1, dated 2025-05-24 β go write some tests, main character π¦β¨
π¦ where this page comes from
- debian trixie: libweasel-perl 0.32-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libweasel-perl 0.32-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libweasel-perl 0.32-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms