Gecko.pm 1.1 KB

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