binary.t 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. $ENV{PATH} .= ':/usr/local/lib/node_modules/protractor/selenium';
  25. my $chrome = Selenium::Chrome->new( %caps );
  26. ok( $chrome->browser_name eq 'chrome', 'convenience chrome is okay' );
  27. isnt( $chrome->port, 4444, 'chrome can start up its own binary');
  28. ok( Selenium::BinaryModeBuilder::probe_port( $chrome->port ), 'the chrome binary is listening on its port');
  29. }
  30. FIREFOX: {
  31. my $binary = Selenium::Firefox::Binary::firefox_path();
  32. ok(-x $binary, 'we can find some sort of firefox');
  33. my $command = Selenium::BinaryModeBuilder::_construct_command('firefox', 1234);
  34. ok($command =~ /firefox -no-remote/, 'firefox command has proper args');
  35. my $firefox = Selenium::Firefox->new;
  36. isnt( $firefox->port, 4444, 'firefox can start up its own binary');
  37. ok( Selenium::BinaryModeBuilder::probe_port( $firefox->port ), 'the firefox binary is listening on its port');
  38. }
  39. done_testing;