Safari.pm 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package Selenium::Driver::Safari;
  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 safaridriver
  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('safaridriver');
  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;