Explorar o código

Fix #328: Print error better in varying versions of geckodriver

It appears the output of non-fully implemented functions is inconsistent.
George S. Baugh %!s(int64=8) %!d(string=hai) anos
pai
achega
672cad22ee
Modificáronse 1 ficheiros con 8 adicións e 3 borrados
  1. 8 3
      lib/Selenium/Remote/ErrorHandler.pm

+ 8 - 3
lib/Selenium/Remote/ErrorHandler.pm

@@ -121,10 +121,15 @@ sub process_error {
     # let the end user handle it or we can save it an image file at a temp
     # location & return the path.
 
+    # handle stacktrace-only responses by assuming unknown error
+    my $is_stacktrace = !$resp->{status};
+    $resp->{status} = 13 unless $resp->{status};
+
     my $ret;
-    $ret->{'stackTrace'} = $resp->{'value'}->{'stackTrace'};
-    $ret->{'error'} = $self->STATUS_CODE->{$resp->{'status'}};
-    $ret->{'message'} = $resp->{'value'}->{'message'};
+    #XXX capitalization is inconsistent among geckodriver versions
+    $ret->{'stackTrace'} = $resp->{'value'}->{'stacktrace'} // $resp->{'value'}->{'stackTrace'};
+    $ret->{'error'}      = $is_stacktrace ? $resp->{value}->{error} : $self->STATUS_CODE->{$resp->{'status'}};
+    $ret->{'message'}    = $resp->{'value'}->{'message'};
 
     return $ret;
 }