瀏覽代碼

Ported Firefox profile tests

Emmanuel Peroumalnaik 11 年之前
父節點
當前提交
d020ae90f3
共有 2 個文件被更改,包括 24 次插入20 次删除
  1. 24 20
      t/Firefox-Profile.t
  2. 0 0
      t/mock-recordings/firefox-profile-mock-linux.json

+ 24 - 20
t/Firefox-Profile.t

@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/perl
 
 use strict;
 use warnings;
@@ -10,20 +10,9 @@ use MIME::Base64 qw/decode_base64/;
 use Archive::Extract;
 use File::Temp;
 use JSON;
+use Selenium::Remote::Mock::RemoteConnection;
 use Selenium::Remote::Driver::Firefox::Profile;
 
-BEGIN {
-    if (defined $ENV{'WD_MOCKING_RECORD'} && ($ENV{'WD_MOCKING_RECORD'}==1)) {
-        use t::lib::MockSeleniumWebDriver;
-        my $p = Net::Ping->new("tcp", 2);
-        $p->port_number(4444);
-        unless ($p->ping('localhost')) {
-            plan skip_all => "Selenium server is not running on localhost:4444";
-            exit;
-        }
-        warn "\n\nRecording...\n\n";
-    }
-}
 
 my $record = (defined $ENV{'WD_MOCKING_RECORD'} && ($ENV{'WD_MOCKING_RECORD'}==1))?1:0;
 my $os  = $^O;
@@ -34,7 +23,19 @@ my $mock_file = "firefox-profile-mock-$os.json";
 if (!$record && !(-e "t/mock-recordings/$mock_file")) {
     plan skip_all => "Mocking of tests is not been enabled for this platform";
 }
-t::lib::MockSeleniumWebDriver::register($record,"t/mock-recordings/$mock_file");
+
+my %selenium_args = ( 
+    browser_name => 'firefox'
+);
+if ($record) { 
+    $selenium_args{remote_conn} = Selenium::Remote::Mock::RemoteConnection->new(record => 1);
+}
+else { 
+    $selenium_args{remote_conn} =
+      Selenium::Remote::Mock::RemoteConnection->new( replay => 1,
+        replay_file => "t/mock-recordings/$mock_file" );
+}
+
 
 CUSTOM_EXTENSION_LOADED: {
     my $profile = Selenium::Remote::Driver::Firefox::Profile->new;
@@ -73,10 +74,9 @@ CUSTOM_EXTENSION_LOADED: {
         $encoded = do {local $/ = undef; <$fh>};
         close ($fh);
     }
-
-    my $driver = Selenium::Remote::Driver->new(extra_capabilities => {
-        firefox_profile => $encoded
-    });
+    my %driver_args = %selenium_args; 
+    $driver_args{extra_capabilities} = { firefox_profile => $encoded };
+    my $driver = Selenium::Remote::Driver->new(%driver_args);
 
     ok(defined $driver, "made a driver without dying");
 
@@ -184,12 +184,16 @@ CROAKING: {
 
     {
         eval {
+            my %driver_args = %selenium_args;
+            $driver_args{firefox_profile} = 'clearly invalid';
             my $croakingDriver = Selenium::Remote::Driver->new(
-                firefox_profile => 'clearly invalid!'
+                %driver_args
             );
         };
         ok ($@ =~ /coercion.*failed/, "caught invalid extension in driver constructor");
     }
 }
-
+if ($record) { 
+    $selenium_args{remote_conn}->dump_session_store("t/mock-recordings/$mock_file");
+}
 done_testing;

File diff suppressed because it is too large
+ 0 - 0
t/mock-recordings/firefox-profile-mock-linux.json


Some files were not shown because too many files changed in this diff