Bläddra i källkod

removed the mock logic from S::R::D

Emmanuel Peroumalnaik 11 år sedan
förälder
incheckning
e445acbc26
2 ändrade filer med 10 tillägg och 24 borttagningar
  1. 2 23
      lib/Selenium/Remote/Driver.pm
  2. 8 1
      t/Test-Selenium-Remote-Driver.t

+ 2 - 23
lib/Selenium/Remote/Driver.pm

@@ -20,8 +20,6 @@ use Scalar::Util;
 use Selenium::Remote::RemoteConnection;
 use Selenium::Remote::Commands;
 use Selenium::Remote::WebElement;
-use Selenium::Remote::MockRemoteConnection;
-use Selenium::Remote::MockCommands;
 
 use constant FINDERS => {
     class             => 'class name',
@@ -314,28 +312,15 @@ has 'session_id' => (
 has 'remote_conn' => (
     is      => 'lazy',
     builder => sub {
-        my $self = shift;
-        if ( $self->testing ) {
-            return Selenium::Remote::MockRemoteConnection->new(
-                spec      => $self->spec,
-                mock_cmds => $self->commands,
-            );
-        }
-        else {
+            my $self = shift;
             return Selenium::Remote::RemoteConnection->new(
                 remote_server_addr => $self->remote_server_addr,
                 port               => $self->port,
                 ua                 => $self->ua
             );
-        }
     },
 );
 
-has 'spec' => ( 
-    is => 'ro', 
-    default => sub { {}} ,
-);
-
 has 'ua' => (
     is      => 'lazy',
     builder => sub { return LWP::UserAgent->new }
@@ -344,13 +329,7 @@ has 'ua' => (
 has 'commands' => (
     is      => 'lazy',
     builder => sub {
-        my $self = shift;
-        if ( $self->testing ) {
-            return Selenium::Remote::MockCommands->new;
-        }
-        else {
-            return Selenium::Remote::Commands->new;
-        }
+        return Selenium::Remote::Commands->new;
     },
 );
 

+ 8 - 1
t/Test-Selenium-Remote-Driver.t

@@ -4,6 +4,8 @@ use Test::More;
 use Test::Exception;
 use Test::Selenium::Remote::Driver;
 use Selenium::Remote::WebElement;
+use Selenium::Remote::MockCommands;
+use Selenium::Remote::MockRemoteConnection;
 use Carp;
 
 my $spec = {
@@ -15,8 +17,13 @@ my $spec = {
     },
     getPageSource => sub { return 'this output matches regex'},
 };
+my $mock_commands = Selenium::Remote::MockCommands->new;
 
-my $successful_driver = Test::Selenium::Remote::Driver->new( testing => 1, spec => $spec);
+my $successful_driver =
+  Test::Selenium::Remote::Driver->new(
+    remote_conn => Selenium::Remote::MockRemoteConnection->new( spec => $spec, mock_cmds => $mock_commands ),
+    commands => $mock_commands,
+);
 $successful_driver->find_element_ok('q','find_element_ok works');
 dies_ok { $successful_driver->find_element_ok('notq') } 'find_element_ok dies if element not found';
 $successful_driver->find_no_element_ok('notq','find_no_element_ok works');