Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Selenium2 driver to accept unexpectedAlertBehavior option #338

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
*.phar
composer.lock
vendor
.idea
.DS_Store
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"php": ">=5.3.2",
"behat/behat": "^3.0.5",
"behat/mink": "^1.5",
"symfony/config": "^2.7|^3.0|^4.0"
"symfony/config": "^5.2"
},

"require-dev": {
"behat/mink-goutte-driver": "^1.1",
"phpspec/phpspec": "^2.0"
"behat/mink-goutte-driver": ">=1.1",
"phpspec/phpspec": ">=2.0"
},

"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,64 +68,12 @@ public function buildDriver(array $config)
);
}

if ($this->isGoutte1()) {
$guzzleClient = $this->buildGuzzle3Client($config['guzzle_parameters']);
} elseif ($this->isGuzzle6()) {
$guzzleClient = $this->buildGuzzle6Client($config['guzzle_parameters']);
} else {
$guzzleClient = $this->buildGuzzle4Client($config['guzzle_parameters']);
}

$clientDefinition = new Definition('Behat\Mink\Driver\Goutte\Client', array(
$config['server_parameters'],
$config['server_parameters'] ?: null,
));
$clientDefinition->addMethodCall('setClient', array($guzzleClient));

return new Definition('Behat\Mink\Driver\GoutteDriver', array(
$clientDefinition,
));
}

private function buildGuzzle6Client(array $parameters)
{
// Force the parameters set by default in Goutte to reproduce its behavior
$parameters['allow_redirects'] = false;
$parameters['cookies'] = true;

return new Definition('GuzzleHttp\Client', array($parameters));
}

private function buildGuzzle4Client(array $parameters)
{
// Force the parameters set by default in Goutte to reproduce its behavior
$parameters['allow_redirects'] = false;
$parameters['cookies'] = true;

return new Definition('GuzzleHttp\Client', array(array('defaults' => $parameters)));
}

private function buildGuzzle3Client(array $parameters)
{
// Force the parameters set by default in Goutte to reproduce its behavior
$parameters['redirect.disable'] = true;

return new Definition('Guzzle\Http\Client', array(null, $parameters));
}

private function isGoutte1()
{
$refl = new \ReflectionParameter(array('Goutte\Client', 'setClient'), 0);

if ($refl->getClass() && 'Guzzle\Http\ClientInterface' === $refl->getClass()->getName()) {
return true;
}

return false;
}

private function isGuzzle6()
{
return interface_exists('GuzzleHttp\ClientInterface') &&
version_compare(\GuzzleHttp\ClientInterface::VERSION, '6.0.0', '>=');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ protected function getCapabilitiesNode()
->addDefaultsIfNotSet()
->normalizeKeys(false)
->children()
->scalarNode('unexpectedAlertBehaviour')->end()
->scalarNode('browserName')->end()
->scalarNode('version')->end()
->scalarNode('platform')->end()
Expand Down