1
0

binary.t 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. use FindBin;
  10. use lib $FindBin::Bin . '/lib';
  11. use TestHarness;
  12. my $harness = TestHarness->new(
  13. this_file => $FindBin::Script
  14. );
  15. my %caps = %{ $harness->base_caps };
  16. delete $caps{browser_name};
  17. PHANTOMJS: {
  18. my $phantom = Selenium::PhantomJS->new( %caps );
  19. is( $phantom->browser_name, 'phantomjs', 'binary phantomjs is okay');
  20. isnt( $phantom->port, 4444, 'phantomjs can start up its own binary');
  21. ok( Selenium::BinaryModeBuilder::probe_port( $phantom->port ), 'the phantomjs binary is listening on its port');
  22. }
  23. CHROME: {
  24. # TODO: fix this test, as it's a hack that depends entirely on the
  25. # node module protractor's included `webdriver-manager` binary.
  26. $ENV{PATH} .= ':/usr/local/lib/node_modules/protractor/selenium';
  27. my $chrome = Selenium::Chrome->new( %caps );
  28. ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
  29. isnt( $chrome->port, 4444, 'chrome can start up its own binary');
  30. ok( Selenium::BinaryModeBuilder::probe_port( $chrome->port ), 'the chrome binary is listening on its port');
  31. }
  32. FIREFOX: {
  33. my $binary = Selenium::Firefox::Binary::firefox_path();
  34. ok(-x $binary, 'we can find some sort of firefox');
  35. my $command = Selenium::BinaryModeBuilder::_construct_command('firefox', 1234);
  36. ok($command =~ /firefox -no-remote/, 'firefox command has proper args');
  37. my $firefox = Selenium::Firefox->new;
  38. isnt( $firefox->port, 4444, 'firefox can start up its own binary');
  39. ok( Selenium::BinaryModeBuilder::probe_port( $firefox->port ), 'the firefox binary is listening on its port');
  40. }
  41. done_testing;