1
0

binary.t 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #! /usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Selenium::Firefox::Binary;
  5. use Selenium::Chrome;
  6. use Selenium::PhantomJS;
  7. use Selenium::Firefox;
  8. use Test::More;
  9. unless( $ENV{RELEASE_TESTING} ) {
  10. plan skip_all => "Author tests not required for installation.";
  11. }
  12. PHANTOMJS: {
  13. my $version = `phantomjs -v` // '';
  14. chomp $version;
  15. skip 'PhantomJS binary not found in path', 3
  16. unless is_proper_phantomjs_available($version);
  17. my $phantom = Selenium::PhantomJS->new;
  18. is( $phantom->browser_name, 'phantomjs', 'binary phantomjs is okay');
  19. isnt( $phantom->port, 4444, 'phantomjs can start up its own binary');
  20. ok( Selenium::BinaryModeBuilder::probe_port( $phantom->port ), 'the phantomjs binary is listening on its port');
  21. }
  22. CHROME: {
  23. # TODO: fix this test, as it's a hack that depends entirely on the
  24. # node module protractor's included `webdriver-manager` binary.
  25. $ENV{PATH} .= ':/usr/local/lib/node_modules/protractor/selenium';
  26. my $chrome = Selenium::Chrome->new;
  27. ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
  28. isnt( $chrome->port, 4444, 'chrome can start up its own binary');
  29. ok( Selenium::BinaryModeBuilder::probe_port( $chrome->port ), 'the chrome binary is listening on its port');
  30. }
  31. FIREFOX: {
  32. my $binary = Selenium::Firefox::Binary::firefox_path();
  33. ok(-x $binary, 'we can find some sort of firefox');
  34. my $command = Selenium::BinaryModeBuilder::_construct_command('firefox', 1234);
  35. ok($command =~ /firefox -no-remote/, 'firefox command has proper args');
  36. my $firefox = Selenium::Firefox->new;
  37. isnt( $firefox->port, 4444, 'firefox can start up its own binary');
  38. ok( Selenium::BinaryModeBuilder::probe_port( $firefox->port ), 'the firefox binary is listening on its port');
  39. }
  40. sub is_proper_phantomjs_available {
  41. my ($ver) = @_;
  42. $ver =~ s/\.\d$//;
  43. return $ver >= 1.9;
  44. }
  45. done_testing;