error.t 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #! /usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Test::More;
  5. use Test::Exception;
  6. use IO::Socket::INET;
  7. BEGIN: {
  8. unless (use_ok('Selenium::Remote::Driver')) {
  9. BAIL_OUT("Couldn't load Selenium::Remote::Driver");
  10. exit;
  11. }
  12. }
  13. LOCAL: {
  14. throws_ok(
  15. sub {
  16. Selenium::Remote::Driver->new_from_caps( port => 80 );
  17. }, qr/Selenium server did not return proper status/,
  18. 'Error message for not finding a selenium server is helpful'
  19. );
  20. }
  21. SAUCE: {
  22. SKIP: {
  23. my $host = 'ondemand.saucelabs.com';
  24. my $port = 80;
  25. my $sock = IO::Socket::INET->new(
  26. PeerAddr => $host,
  27. PeerPort => $port,
  28. );
  29. skip 'Cannot reach saucelabs for Sauce error case ', 1
  30. unless $sock;
  31. throws_ok(
  32. sub {
  33. Selenium::Remote::Driver->new_from_caps(
  34. remote_server_addr => $host,
  35. port => $port,
  36. desired_capabilities => {
  37. browserName => 'invalid'
  38. }
  39. );
  40. }, qr/Sauce Labs/, 'Saucelabs errors are passed to user');
  41. }
  42. }
  43. done_testing;