Gecko.pm 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package Selenium::Driver::Gecko;
  2. use strict;
  3. use warnings;
  4. use v5.28;
  5. no warnings 'experimental';
  6. use feature qw/signatures/;
  7. use Carp qw{confess};
  8. use File::Which;
  9. #ABSTRACT: Tell Selenium::Client how to spawn geckodriver
  10. =head1 Mode of Operation
  11. Spawns a geckodriver server on the provided port (which the caller will assign randomly)
  12. Relies on geckodriver being in your $PATH
  13. Pipes log output to ~/.selenium/perl-client/$port.log
  14. =head1 SUBROUTINES
  15. =head2 build_spawn_opts($class,$object)
  16. Builds a command string which can run the driver binary.
  17. All driver classes must build this.
  18. =cut
  19. sub build_spawn_opts($class,$object) {
  20. $object->{driver_class} = $class;
  21. $object->{driver_version} //= '';
  22. $object->{log_file} //= "$object->{client_dir}/perl-client/selenium-$object->{port}.log";
  23. $object->{driver_file} = File::Which::which('geckodriver');
  24. die "Could not find driver!" unless $object->{driver_file};
  25. my @config = ('--port', $object->{port});
  26. # Build command string
  27. $object->{command} //= [
  28. $object->{driver_file},
  29. @config,
  30. ];
  31. return $object;
  32. }
  33. 1;