1
0

Finders.pm 802 B

123456789101112131415161718192021222324252627282930313233343536
  1. package Selenium::Remote::Finders;
  2. # ABSTRACT: Handle construction of generic parameter finders
  3. use Try::Tiny;
  4. use Carp qw/carp/;
  5. use Moo::Role;
  6. use namespace::clean;
  7. =head1 DESCRIPTION
  8. This package just takes care of setting up parameter finders - that
  9. is, the C<find_element_by_.*> versions of the find element
  10. functions. You probably don't need to do anything with this package;
  11. instead, see L<Selenium::Remote::Driver/find_element> documentation
  12. for the specific finder functions.
  13. =cut
  14. sub _build_find_by {
  15. my ($self, $by) = @_;
  16. return sub {
  17. my ($driver, $locator) = @_;
  18. my $strategy = $by;
  19. return try {
  20. return $driver->find_element($locator, $strategy);
  21. }
  22. catch {
  23. carp $_;
  24. return 0;
  25. };
  26. }
  27. }
  28. 1;