1
0
Эх сурвалжийг харах

Tests for base_uri attribute

Eric Johnson 11 жил өмнө
parent
commit
c25d61467b
1 өөрчлөгдсөн 47 нэмэгдсэн , 0 устгасан
  1. 47 0
      t/01-driver.t

+ 47 - 0
t/01-driver.t

@@ -3,6 +3,7 @@ use warnings;
 
 use JSON;
 use Net::Ping;
+use HTTP::Headers;
 use Test::More;
 use Test::LWP::UserAgent;
 use Selenium::Remote::Driver;
@@ -320,6 +321,52 @@ AUTO_CLOSE: {
     $driver->auto_close(1);
 }
 
+BASE_URL: {
+    {
+        package MySeleniumRemoteDriver;
+        use Moo;
+        extends 'Selenium::Remote::Driver';
+        sub _execute_command { $_[2]->{url} }
+        1;
+    }
+
+    my @tests = ({
+        base_url => 'http://example.com',
+        url      => '/foo',
+        expected => 'http://example.com/foo',
+    },{
+        base_url => 'http://example.com/',
+        url      => '/foo',
+        expected => 'http://example.com/foo',
+    },{
+        base_url => 'http://example.com',
+        url      => 'foo',
+        expected => 'http://example.com/foo',
+    },{
+        base_url => 'http://example.com/a',
+        url      => '/foo',
+        expected => 'http://example.com/a/foo',
+    },{
+        base_url => 'http://example.com/a',
+        url      => 'foo',
+        expected => 'http://example.com/a/foo',
+    },{
+        base_url => 'http://example.com/a',
+        url      => 'http://blog.example.com/foo',
+        expected => 'http://blog.example.com/foo',
+    });
+
+    for my $test (@tests) {
+        my $base_url_driver = MySeleniumRemoteDriver->new(
+            browser_name => 'firefox',
+            base_url     => $test->{base_url},
+            testing      => 1,
+        );
+        my $got = $base_url_driver->get($test->{url});
+        is $got, $test->{expected}, "base_url + $test->{url}";
+    }
+}
+
 QUIT: {
     $ret = $driver->quit();
     ok((not defined $driver->{'session_id'}), 'Killed the remote session');