ソースを参照

Fix #355: handle bizarre errors from local_storage methods better

George S. Baugh 8 年 前
コミット
832ed233ff
3 ファイル変更10 行追加6 行削除
  1. 2 2
      at/sanity-chrome.test
  2. 2 2
      at/sanity.test
  3. 6 2
      lib/Selenium/Remote/Spec.pm

+ 2 - 2
at/sanity-chrome.test

@@ -127,8 +127,8 @@ like(exception { $driver->get_orientation() },qr/error/,"get_orientation unavail
 like($driver->upload_file($otherloc),qr/other.html$/,"upload_file fallback works");
 
 #Jinkies, this stuff is cool, it prints the selenium server help page @_@
-#diag explain $driver->get_local_storage_item('whee');
-#diag explain $driver->delete_local_storage_item('whee');
+like( exception { $driver->get_local_storage_item('whee') },qr/help/i,"get_local_storage_item prints help page");
+like( exception { $driver->delete_local_storage_item('whee') },qr/405/i,"get_local_storage_item prints help page");
 
 ok($driver->switch_to_frame($driver->find_element('frame', 'id')),"can switch to frame (WD3)");
 ok($driver->switch_to_frame(),"can switch to parent frame (WD3 only)");

+ 2 - 2
at/sanity.test

@@ -126,8 +126,8 @@ like(exception { $driver->get_orientation() }, qr/unknown command/, "get_orienta
 like($driver->upload_file($otherloc),qr/other.html$/,"upload_file fallback works");
 
 #Jinkies, this stuff is cool, it prints the selenium server help page @_@
-#diag explain $driver->get_local_storage_item('whee');
-#diag explain $driver->delete_local_storage_item('whee');
+like( exception { $driver->get_local_storage_item('whee') },qr/help/i,"get_local_storage_item prints help page");
+like( exception { $driver->delete_local_storage_item('whee') },qr/405/i,"get_local_storage_item prints help page");
 
 ok($driver->switch_to_frame($driver->find_element('frame', 'id')),"can switch to frame (WD3)");
 ok($driver->switch_to_frame(),"can switch to parent frame (WD3 only)");

+ 6 - 2
lib/Selenium/Remote/Spec.pm

@@ -229,8 +229,12 @@ sub parse_response {
             return $resp->{cmd_return};
         }
         my $msg = "Error while executing command";
-        $msg .= ": $resp->{cmd_return}{error}"   if $resp->{cmd_return}{error};
-        $msg .= ": $resp->{cmd_return}{message}" if $resp->{cmd_return}{message};
+        if (ref $resp->{cmd_return} eq 'HASH' ) {
+            $msg .= ": $resp->{cmd_return}{error}"   if $resp->{cmd_return}{error};
+            $msg .= ": $resp->{cmd_return}{message}" if $resp->{cmd_return}{message};
+        } else {
+            $msg .= ": $resp->{cmd_return}";
+        }
         croak $msg;
     }