Refactored the handling of Selenium2 capabilities
Saucelabs-specific capabilities are removed from the Selenium2Factory in favor of the SaucelabsFactory. The SaucelabsFactory now supports all normal capabilities (inherited from the Selenium2Factory) and the list of Saucelabs-specific ones is completed.
This commit is contained in:
@@ -11,9 +11,8 @@
|
|||||||
namespace Behat\MinkExtension\ServiceContainer\Driver;
|
namespace Behat\MinkExtension\ServiceContainer\Driver;
|
||||||
|
|
||||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||||
use Symfony\Component\DependencyInjection\Definition;
|
|
||||||
|
|
||||||
class SaucelabsFactory implements DriverFactory
|
class SaucelabsFactory extends Selenium2Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@@ -23,14 +22,6 @@ class SaucelabsFactory implements DriverFactory
|
|||||||
return 'saucelabs';
|
return 'saucelabs';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function supportsJavascript()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@@ -42,19 +33,7 @@ class SaucelabsFactory implements DriverFactory
|
|||||||
->scalarNode('access_key')->defaultValue(getenv('SAUCE_ACCESS_KEY'))->end()
|
->scalarNode('access_key')->defaultValue(getenv('SAUCE_ACCESS_KEY'))->end()
|
||||||
->booleanNode('connect')->defaultFalse()->end()
|
->booleanNode('connect')->defaultFalse()->end()
|
||||||
->scalarNode('browser')->defaultValue('firefox')->end()
|
->scalarNode('browser')->defaultValue('firefox')->end()
|
||||||
->arrayNode('capabilities')
|
->append($this->getCapabilitiesNode())
|
||||||
->addDefaultsIfNotSet()
|
|
||||||
->normalizeKeys(false)
|
|
||||||
->children()
|
|
||||||
->scalarNode('name')->defaultValue('Behat feature suite')->end()
|
|
||||||
->scalarNode('platform')->defaultValue('Linux')->end()
|
|
||||||
->scalarNode('version')->defaultValue('21')->end()
|
|
||||||
->scalarNode('selenium-version')->defaultValue('2.31.0')->end()
|
|
||||||
->scalarNode('max-duration')->defaultValue('300')->end()
|
|
||||||
->scalarNode('deviceType')->defaultNull()->end()
|
|
||||||
->scalarNode('deviceOrientation')->defaultNull()->end()
|
|
||||||
->end()
|
|
||||||
->end()
|
|
||||||
->end()
|
->end()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -64,11 +43,6 @@ class SaucelabsFactory implements DriverFactory
|
|||||||
*/
|
*/
|
||||||
public function buildDriver(array $config)
|
public function buildDriver(array $config)
|
||||||
{
|
{
|
||||||
if (!class_exists('Behat\Mink\Driver\Selenium2Driver')) {
|
|
||||||
throw new \RuntimeException(
|
|
||||||
'Install MinkSelenium2Driver in order to use saucelabs driver.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$capabilities = $config['capabilities'];
|
$capabilities = $config['capabilities'];
|
||||||
$capabilities['tags'] = array(php_uname('n'), 'PHP '.phpversion());
|
$capabilities['tags'] = array(php_uname('n'), 'PHP '.phpversion());
|
||||||
|
|
||||||
@@ -83,10 +57,34 @@ class SaucelabsFactory implements DriverFactory
|
|||||||
$host = 'localhost:4445';
|
$host = 'localhost:4445';
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Definition('Behat\Mink\Driver\Selenium2Driver', array(
|
$config['capabilities'] = $capabilities;
|
||||||
$config['browser'],
|
$config['wd_host'] = sprintf('%s:%s@%s/wd/hub', $config['username'], $config['access_key'], $host);
|
||||||
$capabilities,
|
|
||||||
sprintf('%s:%s@%s/wd/hub', $config['username'], $config['access_key'], $host),
|
return parent::buildDriver($config);
|
||||||
));
|
}
|
||||||
|
|
||||||
|
protected function getCapabilitiesNode()
|
||||||
|
{
|
||||||
|
$node = parent::getCapabilitiesNode();
|
||||||
|
|
||||||
|
$node
|
||||||
|
->children()
|
||||||
|
->scalarNode('name')->defaultValue('Behat feature suite')->end()
|
||||||
|
->scalarNode('platform')->defaultValue('Linux')->end()
|
||||||
|
->scalarNode('selenium-version')->defaultValue('2.31.0')->end()
|
||||||
|
->scalarNode('max-duration')->defaultValue('300')->end()
|
||||||
|
->scalarNode('build')->info('will be set automatically based on the TRAVIS_JOB_NUMBER environment variable if available')->end()
|
||||||
|
->arrayNode('custom-data')
|
||||||
|
->useAttributeAsKey('')
|
||||||
|
->prototype('variable')->end()
|
||||||
|
->end()
|
||||||
|
->booleanNode('record-video')->end()
|
||||||
|
->booleanNode('record-screenshots')->end()
|
||||||
|
->booleanNode('capture-html')->end()
|
||||||
|
->booleanNode('disable-popup-handler')->end()
|
||||||
|
->end()
|
||||||
|
;
|
||||||
|
|
||||||
|
return $node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,21 +39,48 @@ class Selenium2Factory implements DriverFactory
|
|||||||
$builder
|
$builder
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('browser')->defaultValue('%mink.browser_name%')->end()
|
->scalarNode('browser')->defaultValue('%mink.browser_name%')->end()
|
||||||
->arrayNode('capabilities')
|
->append($this->getCapabilitiesNode())
|
||||||
|
->scalarNode('wd_host')->defaultValue('http://localhost:4444/wd/hub')->end()
|
||||||
|
->end()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function buildDriver(array $config)
|
||||||
|
{
|
||||||
|
if (!class_exists('Behat\Mink\Driver\Selenium2Driver')) {
|
||||||
|
throw new \RuntimeException(sprintf(
|
||||||
|
'Install MinkSelenium2Driver in order to use %s driver.',
|
||||||
|
$this->getDriverName()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Definition('Behat\Mink\Driver\Selenium2Driver', array(
|
||||||
|
$config['browser'],
|
||||||
|
$config['capabilities'],
|
||||||
|
$config['wd_host'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getCapabilitiesNode()
|
||||||
|
{
|
||||||
|
$node = new ArrayNodeDefinition('capabilities');
|
||||||
|
|
||||||
|
$node
|
||||||
->addDefaultsIfNotSet()
|
->addDefaultsIfNotSet()
|
||||||
->normalizeKeys(false)
|
->normalizeKeys(false)
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('browserName')->defaultValue('firefox')->end()
|
->scalarNode('browserName')->defaultValue('firefox')->end()
|
||||||
->scalarNode('version')->defaultValue('9')->end()
|
->scalarNode('version')->defaultValue('21')->end()
|
||||||
->scalarNode('platform')->defaultValue('ANY')->end()
|
->scalarNode('platform')->defaultValue('ANY')->end()
|
||||||
->scalarNode('browserVersion')->defaultValue('9')->end()
|
->scalarNode('browserVersion')->defaultValue('9')->end()
|
||||||
->scalarNode('browser')->defaultValue('firefox')->end()
|
->scalarNode('browser')->defaultValue('firefox')->end()
|
||||||
->scalarNode('ignoreZoomSetting')->defaultValue('false')->end()
|
->scalarNode('ignoreZoomSetting')->defaultValue('false')->end()
|
||||||
->scalarNode('name')->defaultValue('Behat Test')->end()
|
->scalarNode('name')->defaultValue('Behat feature suite')->end()
|
||||||
->scalarNode('deviceOrientation')->defaultValue('portrait')->end()
|
->scalarNode('deviceOrientation')->defaultValue('portrait')->end()
|
||||||
->scalarNode('deviceType')->defaultValue('tablet')->end()
|
->scalarNode('deviceType')->defaultValue('tablet')->end()
|
||||||
->scalarNode('selenium-version')->defaultValue('2.31.0')->end()
|
|
||||||
->scalarNode('max-duration')->defaultValue('300')->end()
|
|
||||||
->booleanNode('javascriptEnabled')->end()
|
->booleanNode('javascriptEnabled')->end()
|
||||||
->booleanNode('databaseEnabled')->end()
|
->booleanNode('databaseEnabled')->end()
|
||||||
->booleanNode('locationContextEnabled')->end()
|
->booleanNode('locationContextEnabled')->end()
|
||||||
@@ -63,11 +90,6 @@ class Selenium2Factory implements DriverFactory
|
|||||||
->booleanNode('rotatable')->end()
|
->booleanNode('rotatable')->end()
|
||||||
->booleanNode('acceptSslCerts')->end()
|
->booleanNode('acceptSslCerts')->end()
|
||||||
->booleanNode('nativeEvents')->end()
|
->booleanNode('nativeEvents')->end()
|
||||||
->booleanNode('passed')->end()
|
|
||||||
->booleanNode('record-video')->end()
|
|
||||||
->booleanNode('record-screenshots')->end()
|
|
||||||
->booleanNode('capture-html')->end()
|
|
||||||
->booleanNode('disable-popup-handler')->end()
|
|
||||||
->arrayNode('proxy')
|
->arrayNode('proxy')
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('proxyType')->end()
|
->scalarNode('proxyType')->end()
|
||||||
@@ -103,28 +125,8 @@ class Selenium2Factory implements DriverFactory
|
|||||||
->arrayNode('extensions')->prototype('scalar')->end()->end()
|
->arrayNode('extensions')->prototype('scalar')->end()->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end();
|
||||||
->end()
|
|
||||||
->scalarNode('wd_host')->defaultValue('http://localhost:4444/wd/hub')->end()
|
|
||||||
->end()
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return $node;
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function buildDriver(array $config)
|
|
||||||
{
|
|
||||||
if (!class_exists('Behat\Mink\Driver\Selenium2Driver')) {
|
|
||||||
throw new \RuntimeException(
|
|
||||||
'Install MinkSelenium2Driver in order to use selenium2 driver.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Definition('Behat\Mink\Driver\Selenium2Driver', array(
|
|
||||||
$config['browser'],
|
|
||||||
$config['capabilities'],
|
|
||||||
$config['wd_host'],
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user