Преглед на файлове

Handle the Saucelabs error message error case

There is some complicated stuff going on in RemoteConnection.pm's
`_process_response` and Driver.pm's `execute_command`. `_process_response`
sends back different data structures depending on a couple flags, like
status code, whether or not the response is json, etc
etc. `execute_command` unwinds that logic in Driver.pm in order to get at
the necessary messaging or values, as may be the case.

But, when starting up a new session via Driver.pm's
_request_new_session, we do not use the `execute_command` subroutine to
to send the request and handle the response, so we lose out on that
complicated unwinding. This leads to things like error messages from
Saucelabs not showing up because the return value from `_process_response`
is of an unexpected structure.

There is some risk to this, as the error branches in `_process_response`
are used in every front-facing Driver.pm subroutine, but it should be
properly handled in `execute_command` by this portion:

    elsif ( $resp->{cmd_return} ) {
        if ( ref( $resp->{cmd_return} ) eq 'HASH' ) {
            $msg .= ": $resp->{cmd_return}->{error}->{msg}"
              if $resp->{cmd_return}->{error}->{msg};
            $msg .= ": $resp->{cmd_return}->{message}"
              if $resp->{cmd_return}->{message};
        }
        else {
            $msg .= ": $resp->{cmd_return}";
        }
    }
    croak $msg;
Daniel Gempesaw преди 11 години
родител
ревизия
270eb5021f
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      lib/Selenium/Remote/RemoteConnection.pm

+ 1 - 1
lib/Selenium/Remote/RemoteConnection.pm

@@ -118,7 +118,7 @@ sub _process_response {
         if (($response->message ne 'No Content') && ($response->content ne '')) {
             if ($response->content_type !~ m/json/i) {
                 $data->{'cmd_status'} = 'NOTOK';
-                $data->{'cmd_return'} = 'Server returned error message '.$response->content.' instead of data';
+                $data->{'cmd_return'}->{message} = 'Server returned error message '.$response->content.' instead of data';
                 return $data;
             }
             $decoded_json = $json->allow_nonref(1)->utf8(1)->decode($response->content);