4 * This file is part of the Behat MinkExtension.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\MinkExtension\ServiceContainer\Driver;
13 use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
15 class SauceLabsFactory extends Selenium2Factory
20 public function getDriverName()
28 public function configure(ArrayNodeDefinition $builder)
32 ->scalarNode('username')->defaultValue(getenv('SAUCE_USERNAME'))->end()
33 ->scalarNode('access_key')->defaultValue(getenv('SAUCE_ACCESS_KEY'))->end()
34 ->booleanNode('connect')->defaultFalse()->end()
35 ->scalarNode('browser')->defaultValue('firefox')->end()
36 ->append($this->getCapabilitiesNode())
44 public function buildDriver(array $config)
46 $host = 'ondemand.saucelabs.com';
47 if ($config['connect']) {
48 $host = 'localhost:4445';
51 $config['wd_host'] = sprintf('%s:%s@%s/wd/hub', $config['username'], $config['access_key'], $host);
53 return parent::buildDriver($config);
56 protected function getCapabilitiesNode()
58 $node = parent::getCapabilitiesNode();
62 ->scalarNode('platform')->defaultValue('Linux')->end()
63 ->scalarNode('selenium-version')->end()
64 ->scalarNode('max-duration')->end()
65 ->scalarNode('command-timeout')->end()
66 ->scalarNode('idle-timeout')->end()
67 ->scalarNode('build')->info('will be set automatically based on the TRAVIS_BUILD_NUMBER environment variable if available')->end()
68 ->arrayNode('custom-data')
69 ->useAttributeAsKey('')
70 ->prototype('variable')->end()
72 ->scalarNode('screen-resolution')->end()
73 ->scalarNode('tunnel-identifier')->info('will be set automatically based on the TRAVIS_JOB_NUMBER environment variable if available')->end()
76 ->scalarNode('executable')->isRequired()->end()
77 ->arrayNode('args')->prototype('scalar')->end()->end()
78 ->booleanNode('background')->defaultFalse()->end()
81 ->booleanNode('record-video')->end()
82 ->booleanNode('record-screenshots')->end()
83 ->booleanNode('capture-html')->end()
84 ->booleanNode('disable-popup-handler')->end()
87 ->ifTrue(function ($v) {return empty($v['custom-data']);})
88 ->then(function ($v) {
89 unset ($v['custom-data']);