1
0

Remote-Connection.t 920 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #! /usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Test::More;
  5. use Test::Exception;
  6. use Test::LWP::UserAgent;
  7. BEGIN: {
  8. unless (use_ok('Selenium::Remote::RemoteConnection')) {
  9. BAIL_OUT("Couldn't load Selenium::Remote::RemoteConnection");
  10. exit;
  11. }
  12. }
  13. REDIRECT: {
  14. my $tua = Test::LWP::UserAgent->new(
  15. max_redirect => 0
  16. );
  17. $tua->map_response(qr/redirect/, HTTP::Response->new(303, undef, ['Location' => 'http://localhost/elsewhere']));
  18. $tua->map_response(qr/elsewhere/, HTTP::Response->new(200, 'OK', undef, ''));
  19. my $conn = Selenium::Remote::RemoteConnection->new(
  20. remote_server_addr => 'localhost',
  21. port => '',
  22. ua => $tua
  23. );
  24. my $redirect_endpoint = {
  25. method => 'GET',
  26. url => 'http://localhost/redirect'
  27. };
  28. lives_ok(sub { $conn->request($redirect_endpoint) }, '303 redirects no longer kill us');
  29. }
  30. done_testing;