|
|
@@ -4,7 +4,8 @@ use strict;
|
|
|
use warnings;
|
|
|
use Data::Dumper;
|
|
|
|
|
|
-use Carp qw(croak);
|
|
|
+use Carp;
|
|
|
+our @CARP_NOT;
|
|
|
|
|
|
use Selenium::Remote::RemoteConnection;
|
|
|
use Selenium::Remote::Commands;
|
|
|
@@ -215,7 +216,7 @@ sub _execute_command {
|
|
|
$msg .= ": $resp->{cmd_error}" if $resp->{cmd_error};
|
|
|
} else {
|
|
|
if(ref($resp->{cmd_return}) eq 'HASH') {
|
|
|
- $msg .= ": $resp->{cmd_return}->{error}->{msg}"
|
|
|
+ $msg .= ": $resp->{cmd_return}->{error}->{msg}"
|
|
|
if $resp->{cmd_return}->{error}->{msg};
|
|
|
} else {
|
|
|
$msg .= ": $resp->{cmd_return}";
|
|
|
@@ -1019,7 +1020,18 @@ sub find_element {
|
|
|
if (defined $using) {
|
|
|
my $res = { 'command' => 'findElement' };
|
|
|
my $params = { 'using' => $using, 'value' => $query };
|
|
|
- my $ret_data = $self->_execute_command( $res, $params );
|
|
|
+ my $ret_data = eval { $self->_execute_command( $res, $params ); };
|
|
|
+ if($@) {
|
|
|
+ if($@ =~ /(An element could not be located on the page using the given search parameters)/) {
|
|
|
+ # give details on what element wasn't found
|
|
|
+ $@ = "$1: $query,$using";
|
|
|
+ local @CARP_NOT = ("Selenium::Remote::Driver",@CARP_NOT);
|
|
|
+ croak $@;
|
|
|
+ } else {
|
|
|
+ # re throw if the exception wasn't what we expected
|
|
|
+ die $@;
|
|
|
+ }
|
|
|
+ }
|
|
|
return new Selenium::Remote::WebElement($ret_data->{ELEMENT}, $self);
|
|
|
}
|
|
|
else {
|
|
|
@@ -1060,7 +1072,18 @@ sub find_elements {
|
|
|
if (defined $using) {
|
|
|
my $res = { 'command' => 'findElements' };
|
|
|
my $params = { 'using' => $using, 'value' => $query };
|
|
|
- my $ret_data = $self->_execute_command( $res, $params );
|
|
|
+ my $ret_data = eval {$self->_execute_command( $res, $params );};
|
|
|
+ if($@) {
|
|
|
+ if($@ =~ /(An element could not be located on the page using the given search parameters)/) {
|
|
|
+ # give details on what element wasn't found
|
|
|
+ $@ = "$1: $query,$using";
|
|
|
+ local @CARP_NOT = ("Selenium::Remote::Driver",@CARP_NOT);
|
|
|
+ croak $@;
|
|
|
+ } else {
|
|
|
+ # re throw if the exception wasn't what we expected
|
|
|
+ die $@;
|
|
|
+ }
|
|
|
+ }
|
|
|
my $elem_obj_arr;
|
|
|
my $i = 0;
|
|
|
foreach (@$ret_data) {
|
|
|
@@ -1110,7 +1133,18 @@ sub find_child_element {
|
|
|
if (exists FINDERS->{$using}) {
|
|
|
my $res = { 'command' => 'findChildElement', 'id' => $elem->{id} };
|
|
|
my $params = { 'using' => $using, 'value' => $query };
|
|
|
- my $ret_data = $self->_execute_command( $res, $params );
|
|
|
+ my $ret_data = eval {$self->_execute_command( $res, $params );};
|
|
|
+ if($@) {
|
|
|
+ if($@ =~ /(An element could not be located on the page using the given search parameters)/) {
|
|
|
+ # give details on what element wasn't found
|
|
|
+ $@ = "$1: $query,$using";
|
|
|
+ local @CARP_NOT = ("Selenium::Remote::Driver",@CARP_NOT);
|
|
|
+ croak $@;
|
|
|
+ } else {
|
|
|
+ # re throw if the exception wasn't what we expected
|
|
|
+ die $@;
|
|
|
+ }
|
|
|
+ }
|
|
|
return new Selenium::Remote::WebElement($ret_data->{ELEMENT}, $self);
|
|
|
}
|
|
|
else {
|
|
|
@@ -1155,7 +1189,18 @@ sub find_child_elements {
|
|
|
if (exists FINDERS->{$using}) {
|
|
|
my $res = { 'command' => 'findChildElements', 'id' => $elem->{id} };
|
|
|
my $params = { 'using' => $using, 'value' => $query };
|
|
|
- my $ret_data = $self->_execute_command( $res, $params );
|
|
|
+ my $ret_data = eval {$self->_execute_command( $res, $params );};
|
|
|
+ if($@) {
|
|
|
+ if($@ =~ /(An element could not be located on the page using the given search parameters)/) {
|
|
|
+ # give details on what element wasn't found
|
|
|
+ $@ = "$1: $query,$using";
|
|
|
+ local @CARP_NOT = ("Selenium::Remote::Driver",@CARP_NOT);
|
|
|
+ croak $@;
|
|
|
+ } else {
|
|
|
+ # re throw if the exception wasn't what we expected
|
|
|
+ die $@;
|
|
|
+ }
|
|
|
+ }
|
|
|
my $elem_obj_arr;
|
|
|
my $i = 0;
|
|
|
foreach (@$ret_data) {
|