1
0

Firefox.pm 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package Selenium::Firefox;
  2. # ABSTRACT: A convenience package for creating a Firefox instance
  3. use Moo;
  4. with 'Selenium::CanStartBinary';
  5. extends 'Selenium::Remote::Driver';
  6. =head1 SYNOPSIS
  7. my $driver = Selenium::Firefox->new;
  8. =head1 DESCRIPTION
  9. This class allows you to use the FirefoxDriver without needing the JRE
  10. or a selenium server running. When you refrain from passing the
  11. C<remote_server_addr> and C<port> arguments, we will search for the
  12. Firefox executable in your $PATH. We'll try to start the binary
  13. connect to it, shutting it down at the end of the test.
  14. If the Firefox application is not found in the expected places, we'll
  15. fall back to the default L<Selenium::Remote::Driver> behavior of
  16. assuming defaults of 127.0.0.1:4444 after waiting a few seconds.
  17. If you specify a remote server address, or a port, we'll assume you
  18. know what you're doing and take no additional behavior.
  19. If you're curious whether your Selenium::Firefox instance is using a
  20. separate Firefox binary, or through the selenium server, you can check
  21. the C<binary_mode> attr after instantiation.
  22. =cut
  23. has '+browser_name' => (
  24. is => 'ro',
  25. default => sub { 'firefox' }
  26. );
  27. # By shadowing the parent's port, we can set it in _build_binary_mode properly
  28. has '+port' => (
  29. is => 'lazy',
  30. default => sub { 4444 }
  31. );
  32. has 'binary_name' => (
  33. is => 'lazy',
  34. default => sub { 'firefox' }
  35. );
  36. has 'binary_port' => (
  37. is => 'lazy',
  38. default => sub { 9090 }
  39. );
  40. 1;