浏览代码

Require binary & binary_port when consuming CanStartBinary

Daniel Gempesaw 10 年之前
父节点
当前提交
2914736a62
共有 4 个文件被更改,包括 23 次插入12 次删除
  1. 18 9
      lib/Selenium/CanStartBinary.pm
  2. 2 1
      lib/Selenium/Chrome.pm
  3. 2 1
      lib/Selenium/Firefox.pm
  4. 1 1
      lib/Selenium/PhantomJS.pm

+ 18 - 9
lib/Selenium/CanStartBinary.pm

@@ -43,22 +43,31 @@ set up any necessary environments, and start up the binary.
 
 There's a number of TODOs left over - namely Windows support is
 severely lacking, and we're pretty naive when we attempt to locate the
-executables on our own. You may be well served in specifying the paths
-to the webdriver in question yourself, if we can't figure it out.
+executables on our own.
+
+In the following documentation, C<required> refers to when you're
+consuming the role, not the C<required> when you're instantiating a
+class that has already consumed the role.
 
 =attr binary
 
-Optional: specify the path to the executable in question. If you don't
-specify anything, we use L<File::Which/which> and take our best guess
-as to where the proper executable might be. If the expected executable
-is in your C<$PATH>, you shouldn't have to use this attribute.
+Required: Specify the path to the executable in question, or the name
+of the executable for us to find via L<File::Which/which>.
+
+=cut
+
+requires 'binary';
+
+=attr binary_port
 
-As always, make sure _not_ to specify the C<remote_server_addr> and
-C<port> when instantiating your class, or we'll have no choice but to
-assume you're running a Remote Webdriver instance.
+Required: Specify a default port that for the webdriver binary to try
+to bind to. If that port is unavailable, we'll probe above that port
+until we find a valid one.
 
 =cut
 
+requires 'binary_port';
+
 has 'binary_mode' => (
     is => 'lazy',
     init_arg => undef,

+ 2 - 1
lib/Selenium/Chrome.pm

@@ -2,7 +2,6 @@ package Selenium::Chrome;
 
 # ABSTRACT: A convenience package for creating a Chrome instance
 use Moo;
-with 'Selenium::CanStartBinary';
 extends 'Selenium::Remote::Driver';
 
 =head1 SYNOPSIS
@@ -52,6 +51,8 @@ has 'binary_port' => (
     default => sub { 9515 }
 );
 
+with 'Selenium::CanStartBinary';
+
 sub DEMOLISH {
     my ($self) = @_;
 

+ 2 - 1
lib/Selenium/Firefox.pm

@@ -2,7 +2,6 @@ package Selenium::Firefox;
 
 # ABSTRACT: A convenience package for creating a Firefox instance
 use Moo;
-with 'Selenium::CanStartBinary';
 extends 'Selenium::Remote::Driver';
 
 =head1 SYNOPSIS
@@ -52,4 +51,6 @@ has 'binary_port' => (
     default => sub { 9090 }
 );
 
+with 'Selenium::CanStartBinary';
+
 1;

+ 1 - 1
lib/Selenium/PhantomJS.pm

@@ -2,7 +2,6 @@ package Selenium::PhantomJS;
 
 # ABSTRACT: A convenience package for creating a PhantomJS instance
 use Moo;
-with 'Selenium::CanStartBinary';
 extends 'Selenium::Remote::Driver';
 
 =head1 SYNOPSIS
@@ -58,5 +57,6 @@ sub DEMOLISH {
 
     $self->shutdown_binary;
 }
+with 'Selenium::CanStartBinary';
 
 1;