Weasel...erRole(3pm)
π NAME π
Weasel::DriverRole β bestie, it's the API definition for driver wrappers. That's the whole vibe. β¨
(also hi, this is the Weasel...erRole(3pm) page from the User Contributed Perl Documentation corner of the universe π«Ά)
πΈ VERSION πΈ
0.04 β yes queen, we're on 0.04.
π SYNOPSIS π
use Moose;
use Weasel::DriverRole;
with 'Weasel::DriverRole';
... # (re)implement the functions in Weasel::DriverRole
Like. You roll up, you use Moose, you use Weasel::DriverRole, you with 'Weasel::DriverRole', and thenβ¦ you (re)implement the functions. That's the assignment, babe. π
π¦ DESCRIPTION π¦
Okay so real talk: this module defines the API that every single Weasel driver has to implement. No exceptions, no shortcuts, no "I'll do it later" energy.
And here's the cute lil trick: when you use this role inside your driver implementation module, an abstract method gets implemented in a way that just goes croak() if anybody actually calls it. Like, it exists, it's there, but the second you touch it? It screams. Not me being dramatic, that's literally the design. πΈ
π DEPENDENCIES π
(nothing here bestie, this section is empty in the original β no cap, it's just vibing as a heading)
π ATTRIBUTES π
startedβ Every session gets itself a driver instance, right? Well, thestartedattribute is the boolean that tells you whether that driver is actually ready to receive driver commands or if it's still in its getting-ready era. It's managed by thestartandstopmethods, so those two run the show. π¬
β SUBROUTINES/METHODS β
implementsβ Returns the version number of the API that it fully implements. Full coverage only, no half-doing it. Heads up:Weasel::Sessionmaycarp(aka warn) at the user about mismatching API levels, in case a driver was coded against an earlier version than$Weasel::DriverRole::VERSION. So if your driver's out here living in the past, expect to get called out. πstartβ Lets you set up the driver. It gets invoked before any of the web driver methods listed down in the Web driver methods section below. Warm-up first, performance second. β¨stopβ Lets you tear the driver down. And after tear-down,startmay be called again, so this function should leave the driver in a restartable state. It's giving "we can go again whenever, I'm flexible like that." πrestartβ Stops (if it's started) and then starts the driver. Iconic little refresh moment. π
π Web driver methods π
π§ Terms π§
element_id/parent_idβ These are opaque values that the driver uses to identify DOM elements. Opaque, okay? Don't go trying to read their diary.
Note: The driver should always accept an xpath locator as an id value, as well as id values returned from earlier driver calls. Both. Always. π
π API π
find_all( $parent_id, $locator, $scheme )β Returns the_idvalues for the elements that need to be instantiated, matching the$locatorusingscheme. Depending on whether you're in array or scalar context, you get back either a list or an arrayref. Flexible queen.
Note: there's no function to find a single element. That one's implemented up on the Weasel::Session level. So don't come looking for it here. π
get( $url )β Loads the page at$urlinto the driver's browser (browser emulator). And btw, the$urlthat gets passed in has already been expanded byWeasel::Session, which prepends a registered prefix to it. So it arrives pre-glow-up'd. β¨is_displayed($element_id)β Returns a boolean telling you whether the element indicated by$element_idis interactable (can it be selected, clicked on, etc.). Basically: is it giving main character energy or is it background noise? πwait_for( $callback, retry_timeout => $num, poll_delay => $num, on_timeout => \&cb )β The driver may interpret the'poll_delay'in one of two ways:- The
'poll_delay'equals the number of seconds between the start of successive poll requests - The
'poll_delay'equals the number of seconds to wait between the end of one poll request and the start of the next Since 0.03: Unless an"on_timeout"callback is provided, it willdiewhen the timeout has exceeded. Otherwise, it calls the provided callback instead. Drama avoided, optionally. π
- The
Note: The user should catch inside the callback any exceptions that are thrown inside the callback β unless those exceptions are allowed to terminate further polling attempts. I.e. this function doesn't guard against early termination by catching exceptions. It's not your bodyguard, bestie, you gotta handle that yourself.
clear($element_id)β Clicks on an element if an element id is provided, or on the current mouse location otherwise. Either way, something is getting clicked. π±οΈclick( [ $element_id ] )β Clicks on an element if an element id is provided, or on the current mouse location otherwise. Same energy as above, and yes, the option is optional.dblclick()β Double clicks on the current mouse location. Two clicks. Zero arguments. Periodt. πget_attribute($element_id, $attribute_name)β Returns the value of the attribute named by$attribute_nameof the element indicated by$element_id. Tell me everything, boo. πget_page_source($fh)β Writes aget_page_sourceof the browser's window to the filehandle$fh. Straight into the filehandle, no detours.get_text($element_id)β Returns the HTML content of the element identified by$element_id, the so-called'innerHTML'. The inside scoop. π«set_attribute($element_id, $attribute_name, $value)β DEPRECATED β οΈ Changes the value of the attribute named by$attribute_nameto$valuefor the element identified by$element_id. It's old news now, but it did what it did.get_selected($element_id)β DEPRECATED β οΈ Please use"$self-"get_attribute('selected')>instead. Upgrade your habits, bestie. πset_selected($element_id, $value)β DEPRECATED β οΈ Please use"$self-"set_attribute('selected', $value)>instead. Same deal, same upgrade.screenshot($fh)β Takes a screenshot and writes the image to the file handle$fh. Say cheese. πΈ
Note: In the current version of the driver, it's assumed the driver writes a PNG image. Later versions may add APIs to get/set the type of image generated. So for now: PNG, assumed, don't @ me.
send_keys($element_id, @keys)β Simulates key input into the element identified by$element_id.@keysis an array of (groups of) inputs β multiple multi-character strings may be listed, and in those cases the input gets appended. E.g.
$driver->send_keys($element_id, "hello", ' ', "world");
is valid input to enter the text "hello world" into $element_id. Look at that, we typed a whole sentence. π
Note: Special keys are encoded according to the WebDriver spec. In case a driver implementation needs different encoding of special keys, this function should recode from the values found in WebDriver::KEYS() to the desired code-set. Translation work: handled here. π
tag_name($element_id)β The name of the HTML tag identified by$element_id. Name check, but for tags. π·οΈ
π SEE ALSO π
Weasel
π AUTHOR π
- Erik Huelsmann
π«Ά CONTRIBUTORS π«Ά
- Erik Huelsmann
- Yves Lavoie
π MAINTAINERS π
- Erik Huelsmann
π BUGS AND LIMITATIONS π
Got bugs? (Not the cute kind.) They can be filed in the GitHub issue tracker for the Weasel project:
https://github.com/perl-weasel/weasel/issues
π Other remarks π
Please note that version 0.04 didn't have any functional changes β the version number increase served simply to split out the driver role into a separate dist. So it's a glow-up of the packaging, not the behaviour. Periodt. β¨
π 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>. Come through, the group chat is open. π¬
β LICENSE AND COPYRIGHT β
(C) 2016-2019 Erik Huelsmann
Licensed under the same terms as Perl. Slay, legally speaking. π
and that's the whole page bestie!! π¦π this was Weasel...erRole(3pm), generated for perl v5.32.0 and dated 2021-01-10. mwah, go implement those driver methods, you've got this πβ¨
π¦ where this page comes from
- debian bookworm: libweasel-driverrole-perl 0.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libweasel-driverrole-perl 0.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libweasel-driverrole-perl 0.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libweasel-driverrole-perl 0.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libweasel-driverrole-perl 0.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libweasel-driverrole-perl 0.04-2 Β· 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