1
0

Firefox.pm 1.4 KB

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