Ver Fonte

Add tests for webdriver context attribute

Daniel Gempesaw há 10 anos atrás
pai
commit
7b5a2771f7
2 ficheiros alterados com 25 adições e 0 exclusões
  1. 2 0
      t/01-driver.t
  2. 23 0
      t/Remote-Connection.t

+ 2 - 0
t/01-driver.t

@@ -140,6 +140,8 @@ GRID_STARTUP: {
 CHECK_DRIVER: {
     ok(defined $driver, 'Object loaded fine...');
     ok($driver->isa('Selenium::Remote::Driver'), '...and of right type');
+    ok($driver->does('Selenium::Remote::Driver::CanSetWebdriverContext'),
+       'and can set webdriver context prefix');
     ok(defined $driver->{'session_id'}, 'Established session on remote server');
     $ret = $driver->get_capabilities;
     is($ret->{'browserName'}, 'firefox', 'Right capabilities');

+ 23 - 0
t/Remote-Connection.t

@@ -34,5 +34,28 @@ REDIRECT: {
         '303 redirects no longer kill us');
 }
 
+WD_CONTEXT: {
+    my $tua = Test::LWP::UserAgent->new;
+    my $hit_custom_context = 0;
+    my $response = sub {
+        is($_[0]->uri, 'http://addr:port/test/anything', 'can construct url with custom wd_context' );
+        $hit_custom_context++;
+        return HTTP::Response->new(200, 'OK', undef, '')
+    };
+    $tua->map_response(qr/test/, $response);
+
+    my $conn = Selenium::Remote::RemoteConnection->new(
+        remote_server_addr => 'addr',
+        port => 'port',
+        wd_context_prefix => '/test',
+        ua => $tua
+    );
+
+    my $endpoint = { method => 'GET', url => 'anything' };
+
+    $conn->request($endpoint);
+    ok($hit_custom_context, 'wd_context is set up properly');
+}
+
 
 done_testing;