|
@@ -1,4 +1,4 @@
|
|
|
-#! /usr/bin/perl
|
|
|
|
|
|
|
+#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
use strict;
|
|
|
use warnings;
|
|
use warnings;
|
|
@@ -10,20 +10,9 @@ use MIME::Base64 qw/decode_base64/;
|
|
|
use Archive::Extract;
|
|
use Archive::Extract;
|
|
|
use File::Temp;
|
|
use File::Temp;
|
|
|
use JSON;
|
|
use JSON;
|
|
|
|
|
+use Selenium::Remote::Mock::RemoteConnection;
|
|
|
use Selenium::Remote::Driver::Firefox::Profile;
|
|
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 $record = (defined $ENV{'WD_MOCKING_RECORD'} && ($ENV{'WD_MOCKING_RECORD'}==1))?1:0;
|
|
|
my $os = $^O;
|
|
my $os = $^O;
|
|
@@ -34,7 +23,19 @@ my $mock_file = "firefox-profile-mock-$os.json";
|
|
|
if (!$record && !(-e "t/mock-recordings/$mock_file")) {
|
|
if (!$record && !(-e "t/mock-recordings/$mock_file")) {
|
|
|
plan skip_all => "Mocking of tests is not been enabled for this platform";
|
|
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: {
|
|
CUSTOM_EXTENSION_LOADED: {
|
|
|
my $profile = Selenium::Remote::Driver::Firefox::Profile->new;
|
|
my $profile = Selenium::Remote::Driver::Firefox::Profile->new;
|
|
@@ -73,10 +74,9 @@ CUSTOM_EXTENSION_LOADED: {
|
|
|
$encoded = do {local $/ = undef; <$fh>};
|
|
$encoded = do {local $/ = undef; <$fh>};
|
|
|
close ($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");
|
|
ok(defined $driver, "made a driver without dying");
|
|
|
|
|
|
|
@@ -184,12 +184,16 @@ CROAKING: {
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
eval {
|
|
eval {
|
|
|
|
|
+ my %driver_args = %selenium_args;
|
|
|
|
|
+ $driver_args{firefox_profile} = 'clearly invalid';
|
|
|
my $croakingDriver = Selenium::Remote::Driver->new(
|
|
my $croakingDriver = Selenium::Remote::Driver->new(
|
|
|
- firefox_profile => 'clearly invalid!'
|
|
|
|
|
|
|
+ %driver_args
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
ok ($@ =~ /coercion.*failed/, "caught invalid extension in driver constructor");
|
|
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;
|
|
done_testing;
|