|
@@ -1,11 +1,9 @@
|
|
|
package Selenium::Firefox;
|
|
package Selenium::Firefox;
|
|
|
|
|
|
|
|
# ABSTRACT: A convenience package for creating a Firefox instance
|
|
# ABSTRACT: A convenience package for creating a Firefox instance
|
|
|
-use Selenium::Binary qw/start_binary_on_port/;
|
|
|
|
|
-use Try::Tiny;
|
|
|
|
|
use Moo;
|
|
use Moo;
|
|
|
-use namespace::clean;
|
|
|
|
|
extends 'Selenium::Remote::Driver';
|
|
extends 'Selenium::Remote::Driver';
|
|
|
|
|
+with 'Selenium::BinaryModeBuilder';
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
@@ -26,44 +24,20 @@ has '+port' => (
|
|
|
default => sub { 4444 }
|
|
default => sub { 4444 }
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
-has '+firefox_profile' => (
|
|
|
|
|
- is => 'ro',
|
|
|
|
|
- lazy => 1,
|
|
|
|
|
- coerce => sub {
|
|
|
|
|
- my ($profile) = @_;
|
|
|
|
|
- die unless $profile->isa('Selenium::Firefox::Profile');
|
|
|
|
|
- my $port = _find_open_port_above(FIREFOX_PORT);
|
|
|
|
|
- $profile->add_webdriver($port);
|
|
|
|
|
-
|
|
|
|
|
- return $profile;
|
|
|
|
|
- },
|
|
|
|
|
- default => sub { Selenium::Firefox::Profile->new }
|
|
|
|
|
-);
|
|
|
|
|
-
|
|
|
|
|
has 'binary_mode' => (
|
|
has 'binary_mode' => (
|
|
|
is => 'ro',
|
|
is => 'ro',
|
|
|
init_arg => undef,
|
|
init_arg => undef,
|
|
|
builder => 1
|
|
builder => 1
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
-sub _build_binary_mode {
|
|
|
|
|
- my ($self) = @_;
|
|
|
|
|
-
|
|
|
|
|
- if (! $self->has_remote_server_addr && ! $self->has_port) {
|
|
|
|
|
- try {
|
|
|
|
|
- my $port = start_binary_on_port('firefox', FIREFOX_PORT);
|
|
|
|
|
- $self->port($port);
|
|
|
|
|
- return 1;
|
|
|
|
|
- }
|
|
|
|
|
- catch {
|
|
|
|
|
- warn $_;
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else {
|
|
|
|
|
- return 0;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+has 'binary_name' => (
|
|
|
|
|
+ is => 'lazy',
|
|
|
|
|
+ default => sub { 'firefox' }
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
|
|
+has 'binary_port' => (
|
|
|
|
|
+ is => 'lazy',
|
|
|
|
|
+ default => sub { 9090 }
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
1;
|
|
1;
|