error.t 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. use strict;
  2. use warnings;
  3. use Test::More;
  4. use Test::Fatal;
  5. use Test::LWP::UserAgent;
  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. UNAVAILABLE_BROWSER: {
  14. my $tua = Test::LWP::UserAgent->new;
  15. $tua->map_response(qr{status}, HTTP::Response->new(200, 'OK'));
  16. $tua->map_response(qr{session}, HTTP::Response->new(
  17. 500,
  18. 'Internal Server Error',
  19. ['Content-Type' => 'application/json'],
  20. '{"status":13,"sessionId":null,"value":{"message":"The path to..."} }'
  21. ));
  22. like( exception {
  23. Selenium::Remote::Driver->new_from_caps(
  24. ua => $tua,
  25. desired_capabilities => {
  26. browserName => 'chrome'
  27. }
  28. );
  29. }, qr/Could not create new session.*path to/,
  30. 'Errors in browser configuration are passed to user' );
  31. }
  32. LOCAL: {
  33. like( exception {
  34. Selenium::Remote::Driver->new_from_caps(
  35. port => 80
  36. );
  37. }, qr/Selenium server did not return proper status/,
  38. 'Error message for not finding a selenium server is helpful' );
  39. }
  40. done_testing;