Weasel::Element(3pm)
π Weasel::Element β the base HTML/Widget element class π
okay bestie, welcome to Weasel::Element, a Perl module from the Weasel family (user contributed Perl documentation, iykyk) and honestly? it's the blueprint. it's the blueprint for every page element out there. periodt.
β¨ VERSION β¨
version 0.32 π
πΈ SYNOPSIS πΈ
my $element = $session->page->find("./input[\@name='phone']");
my $value = $element->send_keys('555-885-321');
that's it. that's the whole vibe. π¦
π DESCRIPTION π
so this module is the base class for all page elements, right? and what it does is it wraps up all the regular element interactions you'd ever want β finding child elements, querying attributes, grabbing the tag name, all of it. it's giving foundation. it's giving main character energy for every element class that inherits from it. π
π§ DEPENDENCIES π§
ngl bestie, this section is just sitting here empty. nothing listed. no cap. π
π ATTRIBUTES π
sessionβ Required. holds a reference to theWeasel::Sessionthat this element belongs to. it's how we get at the session's driver so we can go query element properties.x (yes that 'x' is really there, we don't ask questions π)_idβ Required. holds theelement_idthat the session's driver uses to identify the element. it's the element's little ID card. πͺͺ
π₯ SUBROUTINES/METHODS π₯
find($locator [, scheme => $scheme] [, widget_args => \@args ] [, %locator_args])
finds the first child element that matches <$locator>. if it can't find one, it returns "undef". and hey, you can optionally pass a scheme argument to identify non-xpath type locators. π«
and if $locator is a mnemonic (you know, one of those that starts with an asterisk ['*']), you can toss in extra arguments to expand that mnemonic. the standard expanders are documented over in Weasel::FindExpanders::HTML β go read that, bestie. π
anything you pass in that $widget_args array reference gets handed straight to the widget's constructor. π«Ά
find_all($locator [, scheme => $scheme] [, widget_args => \@args ] [, %locator_args])
this one's a little shapeshifter β¨ β depending on whether you're in scalar or array context, it returns a list or an arrayref of the matching elements. found nothing? you get an empty list or a ref to an empty array. you can optionally pass a scheme argument to identify non-xpath type locators, same as above.
and again: if $locator is a mnemonic (starts with an asterisk ['*']), extra arguments may be provided for expanding it. check Weasel::FindExpanders::HTML for the docs on the standard expanders. π
any arguments in that $widget_args array reference get passed to the widget's constructor. π
get_attribute($attribute)
returns the value of the element's attribute named in $attribute, or "undef" if that attribute doesn't exist. simple. iconic. β
Note: some browsers apply default values to attributes that were never part of the original page. so yeah, there's no direct relation between an attribute existing in the original page and this function returning "undef". keep that in mind, bestie. π
Note: if you're coming from Selenium you might be out here looking for a method called"is_selected"or"set_selected". Weasel does not have that short-hand, sorry. use"get_attribute"/"set_attribute"with an attribute name of"selected"instead. that's the move. π
set_attribute($attribute, $value)
sets the value of the element's attribute named in $attribute. π§
Note: Selenium girlies might be hunting for a method called"is_selected"or"set_selected". Weasel doesn't do that short-hand. please use"get_attribute"/"set_attribute"with an attribute name of"selected"instead. π«Ά
get_text()
returns the element's 'innerHTML'. the whole inside, handed to you. π
has_classis_displayed
returns a boolean saying whether the element is visible β like, whether it could potentially be scrolled into the viewport for interaction. π
click()
scrolls the element into the viewport and simulates a click on it. go ahead, tap it. β¨
send_keys(@keys)
focuses the element and simulates keyboard input. @keys can be any number of strings containing unicode characters to send. e.g.
$element->send_keys("hello", ' ', "world");
tag_name()
returns the name of the element's tag β like 'div' or 'input'. π·οΈ
π AUTHOR π
Erik Huelsmann
π CONTRIBUTORS π
Erik Huelsmann, Yves Lavoie
π MAINTAINERS π
Erik Huelsmann
π¨ BUGS AND LIMITATIONS π¨
got bugs? (rude, but okay π) file them in the GitHub issue tracker for the Weasel project:
https://github.com/perl-weasel/weasel/issues
π SOURCE π
the source code repository for Weasel lives at:
https://github.com/perl-weasel/weasel
π«Ά SUPPORT π«Ά
community support is available through perl-weasel@googlegroups.com <mailto:perl-weasel@googlegroups.com>. come hang out. π
β LICENSE AND COPYRIGHT β
(C) 2016-2023 Erik Huelsmann
licensed under the same terms as Perl. slay. π
okay and that's the whole page, bestie β this was Weasel::Element(3pm), page generated by perl v5.40.1 on 2025-05-24, and you absolutely ate for reading all the way to the bottom. mwah. ππβ¨
π¦ 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