浏览代码

Fix #152: Ensure consistent error messaging

This came out of an email discussion where the error message for trying
to start Chromedriver without having previously configured your selenium
server was unhelpful. As per #152, we want to be sure not to muck up the
current error message, as users may rightly be depending on it. So,
we lock it down with a test.
Daniel Gempesaw 11 年之前
父节点
当前提交
384b7b81ac
共有 1 个文件被更改,包括 25 次插入0 次删除
  1. 25 0
      t/error.t

+ 25 - 0
t/error.t

@@ -4,6 +4,7 @@ use strict;
 use warnings;
 use Test::More;
 use Test::Exception;
+use Test::LWP::UserAgent;
 use IO::Socket::INET;
 
 
@@ -14,6 +15,30 @@ BEGIN: {
     }
 }
 
+UNAVAILABLE_BROWSER: {
+    my $tua = Test::LWP::UserAgent->new;
+
+    $tua->map_response(qr{status}, HTTP::Response->new(200, 'OK'));
+    $tua->map_response(qr{session}, HTTP::Response->new(
+        500,
+        'Internal Server Error',
+        ['Content-Type' => 'application/json'],
+        '{"status":13,"sessionId":null,"value":{"message":"The path to..."} }'
+    ));
+
+    throws_ok(
+        sub {
+            Selenium::Remote::Driver->new_from_caps(
+                ua => $tua,
+                desired_capabilities => {
+                    browserName => 'chrome'
+                }
+            );
+        }, qr/Could not create new session.*path to/,
+        'Errors in browser configuration are passed to user'
+    );
+}
+
 LOCAL: {
     throws_ok(
         sub {