use strict;
use warnings;

use Selenium::Firefox;
use Test::More tests => 4;
use Test::Fatal;

my $driver;
is( exception { $driver = Selenium::Firefox->new(
	extra_capabilities => {
        'moz:firefoxOptions' => {
            args    => [ '-headless' ],
        },
    },
); }, undef, "can spawn new Selenium::Firefox");

my $port = $driver->port();

ok($driver->get('http://google.com'),"can load a page");
$driver->quit();

is( exception { $driver->shutdown_binary; }, undef, "can shutdown binary correctly");
sleep 2;

my $cmd = "lsof -t -i :$port";
my $pid = `$cmd`;
chomp $pid;
is($pid,'',"Destructor appears to have run shutdown_binary and whacked the driver process");