Weasel::Element(3pm)

πŸ“¦
version 0.32 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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 the Weasel::Session that 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 the element_id that 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_class
  • is_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. 🌈


(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