|
@@ -12,17 +12,22 @@ use HTTP::Headers;
|
|
|
use HTTP::Request;
|
|
use HTTP::Request;
|
|
|
use Carp qw(croak);
|
|
use Carp qw(croak);
|
|
|
use JSON;
|
|
use JSON;
|
|
|
-use Data::Dumper;
|
|
|
|
|
use Selenium::Remote::ErrorHandler;
|
|
use Selenium::Remote::ErrorHandler;
|
|
|
use Scalar::Util qw{looks_like_number};
|
|
use Scalar::Util qw{looks_like_number};
|
|
|
|
|
|
|
|
-has 'remote_server_addr' => ( is => 'rw', );
|
|
|
|
|
|
|
+has 'remote_server_addr' => (
|
|
|
|
|
+ is => 'rw',
|
|
|
|
|
+ default => '127.0.0.1',
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
-has 'port' => ( is => 'rw', );
|
|
|
|
|
|
|
+has 'port' => (
|
|
|
|
|
+ is => 'rw',
|
|
|
|
|
+ 'default' => 4444,
|
|
|
|
|
+);
|
|
|
|
|
|
|
|
has 'debug' => (
|
|
has 'debug' => (
|
|
|
is => 'rw',
|
|
is => 'rw',
|
|
|
- default => sub { 0 }
|
|
|
|
|
|
|
+ default => 0,
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
has 'ua' => (
|
|
has 'ua' => (
|
|
@@ -100,6 +105,27 @@ sub check_status {
|
|
|
unless ( $cmdOut eq 'OK' ) {
|
|
unless ( $cmdOut eq 'OK' ) {
|
|
|
croak "Selenium server did not return proper status";
|
|
croak "Selenium server did not return proper status";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ # While we're here, let's try to find out what server version we're on.
|
|
|
|
|
+ my $response = $status->{'cmd_out'};
|
|
|
|
|
+ if( ref $response eq 'HASH' ) {
|
|
|
|
|
+ # Selenium 4 pathway
|
|
|
|
|
+ my $curr_component = $response;
|
|
|
|
|
+ my $looks_like_4;
|
|
|
|
|
+ foreach my $key (qw{value nodes 0 version}) {
|
|
|
|
|
+ if( $key eq '0' ) { # We must at least have one node in the grid.
|
|
|
|
|
+ last if !$curr_component->[0];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ last if !$curr_component->{$key};
|
|
|
|
|
+ }
|
|
|
|
|
+ $looks_like_4 = $response->{'value'}{'nodes'}[0]{'version'};
|
|
|
|
|
+ }
|
|
|
|
|
+ if($looks_like_4) {
|
|
|
|
|
+ $self->{'version'} = 4;
|
|
|
|
|
+ $self->{'version_full'} = $looks_like_4;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
=head2 request
|
|
=head2 request
|
|
@@ -216,6 +242,7 @@ sub _process_response {
|
|
|
elsif ( $response->is_success ) {
|
|
elsif ( $response->is_success ) {
|
|
|
$data->{'cmd_status'} = 'OK';
|
|
$data->{'cmd_status'} = 'OK';
|
|
|
if ( defined $decoded_json ) {
|
|
if ( defined $decoded_json ) {
|
|
|
|
|
+ $data->{'cmd_out'} = $decoded_json;
|
|
|
|
|
|
|
|
#XXX MS edge doesn't follow spec here either
|
|
#XXX MS edge doesn't follow spec here either
|
|
|
if ( looks_like_number( $decoded_json->{status} )
|
|
if ( looks_like_number( $decoded_json->{status} )
|