فهرست منبع

Restore coercions for Firefox browser executable

Daniel Gempesaw 9 سال پیش
والد
کامیت
4a56668590
2فایلهای تغییر یافته به همراه21 افزوده شده و 6 حذف شده
  1. 13 2
      lib/Selenium/CanStartBinary/FindBinary.pm
  2. 8 4
      lib/Selenium/Firefox.pm

+ 13 - 2
lib/Selenium/CanStartBinary/FindBinary.pm

@@ -1,7 +1,6 @@
 package Selenium::CanStartBinary::FindBinary;
 
 # ABSTRACT: Coercions for finding webdriver binaries on your system
-use File::Which qw/which/;
 use Cwd qw/abs_path/;
 use File::Which qw/which/;
 use IO::Socket::INET;
@@ -25,6 +24,18 @@ sub coerce_simple_binary {
     }
 }
 
+sub coerce_firefox_binary {
+    my ($executable) = @_;
+
+    my $manual_binary = _validate_manual_binary($executable);
+    if ($manual_binary) {
+        return $manual_binary;
+    }
+    else {
+        return firefox_path();
+    }
+}
+
 sub _validate_manual_binary {
     my ($executable) = @_;
 
@@ -52,7 +63,7 @@ sub _naive_find_binary {
         return $naive_binary;
     }
     else {
-        warn qq(Unable to find the $executable binary in your \$PATH. We'll try falling back to standard Remote Driver);
+        warn qq(Unable to find the $executable binary in your \$PATH.);
         return;
     }
 }

+ 8 - 4
lib/Selenium/Firefox.pm

@@ -2,7 +2,7 @@ package Selenium::Firefox;
 
 # ABSTRACT: Use FirefoxDriver without a Selenium server
 use Moo;
-use Selenium::CanStartBinary::FindBinary qw/coerce_simple_binary/;
+use Selenium::CanStartBinary::FindBinary qw/coerce_simple_binary coerce_firefox_binary/;
 extends 'Selenium::Remote::Driver';
 
 =head1 SYNOPSIS
@@ -103,16 +103,19 @@ has '_binary_args' => (
     builder => sub {
         my ($self) = @_;
 
-        my $args = ' --log trace --port ' . $self->port;
         if ( $self->marionette_enabled ) {
+            my $args = ' --log trace --port ' . $self->port;
             $args .= ' --marionette-port ' . $self->marionette_binary_port;
 
             if ( $self->has_firefox_binary ) {
                 $args .= ' --binary ' . $self->firefox_binary;
             }
-        }
 
-        return $args;
+            return $args;
+        }
+        else {
+            return ' -no-remote';
+        }
     }
 );
 
@@ -181,6 +184,7 @@ directly start up.
 
 has 'firefox_binary' => (
     is => 'lazy',
+    coerce => \&coerce_firefox_binary,
     predicate => 1,
     default => sub { '' }
 );