Преглед на файлове

Record and replay finally work

Emmanuel Peroumalnaik преди 11 години
родител
ревизия
93a5759081
променени са 1 файла, в които са добавени 15 реда и са изтрити 12 реда
  1. 15 12
      lib/Selenium/Remote/Mock/RemoteConnection.pm

+ 15 - 12
lib/Selenium/Remote/Mock/RemoteConnection.pm

@@ -134,22 +134,25 @@ sub request {
                   unless $self->session_id;
             }
         }
-        $self->session_store->{ $self->session_id }->{"$method $url $content"}
-          = $response->as_string
-          if ( $self->session_id );
+        if ($self->session_id) { 
+            push @{$self->session_store->{ $self->session_id }->{"$method $url $content"}},$response->as_string
+    }
         return $self->_process_response( $response, $no_content_success );
     }
     if ( $self->replay ) {
-        my $resp; 
-        if ($self->session_store->{ $self->fake_session_id }
-          ->{"$method $url $content"}) { 
-          $resp =  HTTP::Response->parse($self->session_store->{ $self->fake_session_id }
-          ->{"$method $url $content"}) 
+        my $resp;
+        my $arr_of_resps = $self->session_store->{ $self->fake_session_id }
+          ->{"$method $url $content"};
+        if ( scalar(@$arr_of_resps) ) {
+            $resp = shift @$arr_of_resps;
+            $resp = HTTP::Response->parse($resp);
+        }
+        else {
+            $resp = HTTP::Response->new(
+                '501',
+                "Failed to find a response"
+            );
         }
-        else { 
-        $resp = HTTP::Response->new( '204',
-            "No Content" );
-    }
         return $self->_process_response( $resp, $no_content_success );
     }
     my $mock_cmds = $self->mock_cmds;