CanStartBinary.t 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #! /usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use File::Which qw/which/;
  5. use Selenium::Firefox::Binary;
  6. use Selenium::Chrome;
  7. use Selenium::PhantomJS;
  8. use Selenium::Firefox;
  9. use Test::More;
  10. unless ( $ENV{RELEASE_TESTING} ) {
  11. plan skip_all => "Author tests not required for installation.";
  12. }
  13. PHANTOMJS: {
  14. SKIP: {
  15. my $has_phantomjs = which('phantomjs');
  16. skip 'Phantomjs binary not found in path', 3
  17. unless $has_phantomjs;
  18. skip 'PhantomJS binary not found in path', 3
  19. unless is_proper_phantomjs_available();
  20. my $phantom = Selenium::PhantomJS->new;
  21. is( $phantom->browser_name, 'phantomjs', 'binary phantomjs is okay');
  22. isnt( $phantom->port, 4444, 'phantomjs can start up its own binary');
  23. ok( Selenium::CanStartBinary::probe_port( $phantom->port ), 'the phantomjs binary is listening on its port');
  24. }
  25. }
  26. CHROME: {
  27. SKIP: {
  28. my $has_chromedriver = which('chromedriver');
  29. skip 'Chrome binary not found in path', 3
  30. unless $has_chromedriver;
  31. my $chrome = Selenium::Chrome->new;
  32. ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
  33. isnt( $chrome->port, 4444, 'chrome can start up its own binary');
  34. ok( Selenium::CanStartBinary::probe_port( $chrome->port ), 'the chrome binary is listening on its port');
  35. }
  36. }
  37. FIREFOX: {
  38. my $command = Selenium::CanStartBinary::_construct_command('firefox', 1234);
  39. ok($command =~ /firefox -no-remote/, 'firefox command has proper args');
  40. SKIP: {
  41. my $binary = Selenium::Firefox::Binary::firefox_path();
  42. skip 'Firefox binary not found in path', 3
  43. unless $binary;
  44. ok(-x $binary, 'we can find some sort of firefox');
  45. my $firefox = Selenium::Firefox->new;
  46. isnt( $firefox->port, 4444, 'firefox can start up its own binary');
  47. ok( Selenium::CanStartBinary::probe_port( $firefox->port ), 'the firefox binary is listening on its port');
  48. }
  49. }
  50. sub is_proper_phantomjs_available {
  51. my $ver = `phantomjs -v` // '';
  52. chomp $ver;
  53. $ver =~ s/^(\d\.\d).*/$1/;
  54. return $ver >= 1.9;
  55. }
  56. done_testing;