Weasel::FindExpanders(3pm)

Weasel::FindExpanders3pm

Mapping find patterns to xpath locators

Usage

  use Weasel::FindExpanders qw( register_find_expander );
  register_find_expander(
    'button',
    'HTML',
    sub {
       my %args = @_;
       $args{text} =~ s/'/''/g; # quote the quotes (XPath 2.0)
       return ".//button[text()='$args{text}']";
    });
  $session->find($session->page, "*button|{text=>\"whatever\"}");

Version

version 0.32

Overview

The concept of find expanders is used to define XPath templates for use with the "find" and "find_all" methods. Multiple patterns may be registered with the same pattern name ("mnemonic"); eg, there could be a two patterns associated with the "button" mnemonic, one for the "<button>" tag and one for the "<input type="submit">" tag. Or there could even be more patterns registered, eg., to match Vue, React or Web Component elements. All patterns registered on a single mnemonic (template name) will be compiled into a single XPath expression which will match any of the patterns.

Weasel comes with a standard set of patterns in the Weasel::FindExpanders::HTML package.

Dependencies

Subroutines/methods

register_find_expander($pattern_name, $group_name, &expander_function)

Registers &expander_function as an expander for $pattern_name in $group_name.

"Weasel::Session" selects the expanders to be applied using its "groups" attribute.

expand_finder_pattern($pattern, $args, $groups)

Returns a string of concatenated (using xpath '|' operator) expansions.

When $groups is undef, all groups will be searched for "pattern_name".

If the pattern doesn't match '*<pattern_name>|{<arguments>}', the pattern is returned as the only list/arrayref element.

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 [email protected] <mailto:[email protected]>.

Releases

4 releases since Debian 10 (Buster); the text changed 3 times.

  1. 10
  2. 11
  3. 12
  4. 13

Author

Erik Huelsmann

From libweasel-perl 0.32-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.