瀏覽代碼

Pass self when constructing CMD to make name available

We'll need to name the task something unique in windows so that we can
figure out how to kill it at the end of the run.
Daniel Gempesaw 10 年之前
父節點
當前提交
db448823a0
共有 2 個文件被更改,包括 11 次插入7 次删除
  1. 10 6
      lib/Selenium/CanStartBinary.pm
  2. 1 1
      t/CanStartBinary.t

+ 10 - 6
lib/Selenium/CanStartBinary.pm

@@ -131,7 +131,7 @@ sub start_binary_on_port {
     if (ref($self) eq 'Selenium::Firefox') {
         setup_firefox_binary_env($port);
     }
-    my $command = _construct_command($executable, $port);
+    my $command = $self->_construct_command($executable, $port);
 
     system($command);
     my $success = wait_until { probe_port($port) } timeout => 10;
@@ -185,7 +185,7 @@ sub _find_executable {
 }
 
 sub _construct_command {
-    my ($executable, $port) = @_;
+    my ($self, $executable, $port) = @_;
 
     my %args;
     if ($executable =~ /chromedriver(\.exe)?$/i) {
@@ -206,13 +206,16 @@ sub _construct_command {
     my @args = map { '--' . $_ . '=' . $args{$_} } keys %args;
 
     # Handle Windows vs Unix discrepancies for invoking shell commands
-    my ($prefix, $suffix) = (_command_prefix(), _command_suffix());
+    my ($prefix, $suffix) = ($self->_command_prefix(), $self->_command_suffix());
     return join(' ', ($prefix, $executable, @args, $suffix) );
 }
 
 sub _command_prefix {
+    my ($self) = @_;
+
     if ($^O eq 'MSWin32') {
-        return 'start /MAX '
+        my $title = ref($self) . ':' . $self->binary_port;
+        return 'start "' . $title . '" /MAX '
     }
     else {
         return '';
@@ -220,12 +223,13 @@ sub _command_prefix {
 }
 
 sub _command_suffix {
+    # TODO: allow users to specify whether & where they want driver
+    # output to go
+
     if ($^O eq 'MSWin32') {
         return ' > /nul 2>&1 ';
     }
     else {
-        # TODO: allow users to specify whether & where they want
-        # driver output to go
         return ' > /dev/null 2>&1 &';
     }
 }

+ 1 - 1
t/CanStartBinary.t

@@ -70,7 +70,7 @@ CHROME: {
 }
 
 FIREFOX: {
-    my $command = Selenium::CanStartBinary::_construct_command('firefox', 1234);
+    my $command = Selenium::CanStartBinary->_construct_command('firefox', 1234);
     ok($command =~ /firefox -no-remote/, 'firefox command has proper args');
 
   SKIP: {