Skip to content

Commit 4f04e4f

Browse files
author
Alexander Obuhovich
committed
Merge pull request #49 from aik099/driver-selection-support
Mink driver selection ability in configuration
2 parents 34d163f + dc4109f commit 4f04e4f

37 files changed

+1261
-286
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
"require": {
1616
"php": ">=5.3.2",
17-
"behat/mink": "~1.6",
17+
"behat/mink": "~1.6@dev",
1818
"behat/mink-selenium2-driver": "~1.2",
1919
"symfony/event-dispatcher": "~2.4",
2020
"pimple/pimple": "~2.0|~3.0",

composer.lock

Lines changed: 34 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/configuration.rst

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ configuration) in that test case class.
2121

2222
.. literalinclude:: examples/configuration/config_via_browsers_property.php
2323
:linenos:
24-
:emphasize-lines: 8,9,15
24+
:emphasize-lines: 8,9,16
2525

2626
.. note:: When several browser configurations are specified in ``$browsers`` array, then each test
2727
in a test case will be executed against each of browser configurations.
@@ -35,27 +35,38 @@ option (line 14) to the browser configuration.
3535

3636
.. literalinclude:: examples/configuration/per_test_case_browser_config.php
3737
:linenos:
38-
:emphasize-lines: 14
38+
:emphasize-lines: 15
39+
40+
Selecting the Mink Driver
41+
^^^^^^^^^^^^^^^^^^^^^^^^^
42+
With the help of ``driver`` and ``driverOptions`` browser configuration settings (since v2.1.0) it's possible to
43+
specify which `Mink`_ driver to use. This file demonstrates how to use each driver:
44+
45+
.. literalinclude:: examples/configuration/driver_showcase.php
46+
:linenos:
47+
:emphasize-lines: 10,20,32,40
3948

4049
Configuration Options
4150
^^^^^^^^^^^^^^^^^^^^^
4251
Each browser configuration consists of the following settings (all optional):
4352

44-
======================= =================================================================================================
53+
======================= ==================================================================================================
4554
Name Description
46-
======================= =================================================================================================
47-
``host`` host, where Selenium Server is located (defaults to ``localhost``)
48-
``port`` port, on which Selenium Server is listening for incoming connections (defaults to ``4444``)
49-
``timeout`` connection timeout of the server in seconds (defaults to ``60``)
55+
======================= ==================================================================================================
56+
``driver`` Mink driver name (defaults to ``selenium2``, since v2.1.0)
57+
``driverOptions`` Mink driver specific options (since v2.1.0)
58+
``host`` host, where driver's server is located (defaults to ``localhost``)
59+
``port`` port, on which driver's server is listening for incoming connections (determined by driver)
60+
``timeout`` connection timeout of the server in seconds ('selenium2' driver only, defaults to ``60``)
5061
``browserName`` name of browser to use (e.g. ``firefox``, ``chrome``, etc., defaults to ``firefox``)
51-
``desiredCapabilities`` parameters, that specify additional browser configuration (e.g. browser version, platform, etc.),
52-
that will be used by Selenium server
62+
``desiredCapabilities`` parameters, that allow to fine-tune browser and other 'selenium2' driver options (e.g. 'tags',
63+
'project', 'os', 'version')
5364
``baseUrl`` base url of website, that is tested
5465
``sessionStrategy`` used session strategy (defaults to ``isolated``)
5566
``type`` type of configuration (defaults to ``default``, but can also be ``saucelabs`` or ``browserstack``)
56-
``api_username`` API username of used service (applicable to any but ``default`` configuration type)
57-
``api_key`` API key of used service (applicable to any but ``default`` configuration type)
58-
======================= =================================================================================================
67+
``apiUsername`` API username of used service (applicable to 'saucelabs' and 'browserstack' browser configurations)
68+
``apiKey`` API key of used service (applicable to 'saucelabs' and 'browserstack' browser configurations)
69+
======================= ==================================================================================================
5970

6071
There are also corresponding setters (e.g. ``setHost``) and getters (e.g. ``getHost``) for each of mentioned
6172
above settings, that allow to individually change them from ``setUp`` method before test has started.

docs/examples/browser_aliases.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public function getBrowserAliases()
99
{
1010
return array(
1111
'example_alias' => array(
12+
'driver' => 'selenium2',
1213
'host' => 'localhost',
1314
'port' => 4444,
1415
'browserName' => 'firefox',

docs/examples/configuration/config_via_browsers_property.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ class PerTestCaseBrowserConfigTest extends BrowserTestCase
77

88
public static $browsers = array(
99
array(
10+
'driver' => 'selenium2',
1011
'host' => 'localhost',
1112
'port' => 4444,
1213
'browserName' => 'firefox',
1314
'baseUrl' => 'http://www.google.com',
1415
),
1516
array(
17+
'driver' => 'selenium2',
1618
'host' => 'localhost',
1719
'port' => 4444,
1820
'browserName' => 'chrome',

docs/examples/configuration/config_via_setup_method.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ protected function setUp()
1616
$browser = $this->createBrowserConfiguration(array(
1717
// required
1818
'type' => 'saucelabs',
19-
'api_username' => 'sauce_username',
20-
'api_key' => 'sauce_api_key',
19+
'apiUsername' => 'sauce_username',
20+
'apiKey' => 'sauce_api_key',
2121
// optional options goes here
2222
));
2323

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
use aik099\PHPUnit\BrowserTestCase;
4+
5+
class DriverShowCaseTest extends BrowserTestCase
6+
{
7+
8+
public static $browsers = array(
9+
array(
10+
'driver' => 'goutte',
11+
12+
// Defaults for this driver.
13+
'driverOptions' => array(
14+
'server_parameters' => array(),
15+
'guzzle_parameters' => array(),
16+
),
17+
18+
),
19+
array(
20+
'driver' => 'sahi',
21+
22+
// Defaults for this driver.
23+
'port' => 9999,
24+
'driverOptions' => array(
25+
'sid' => null,
26+
'limit' => 600,
27+
'browser' => null,
28+
),
29+
),
30+
31+
array(
32+
'driver' => 'selenium2',
33+
34+
// Defaults for this driver.
35+
'port' => 4444,
36+
'driverOptions' => array(),
37+
),
38+
39+
array(
40+
'driver' => 'zombie',
41+
42+
// Defaults for this driver.
43+
'port' => 8124,
44+
'driverOptions' => array(
45+
'node_bin' => 'node',
46+
'server_path' => null,
47+
'threshold' => 2000000,
48+
'node_modules_path' => '',
49+
),
50+
),
51+
);
52+
53+
}

docs/examples/configuration/per_test_case_browser_config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class CommonBrowserConfigTest extends BrowserTestCase
77

88
public static $browsers = array(
99
array(
10+
'driver' => 'selenium2',
1011
'host' => 'localhost',
1112
'port' => 4444,
1213
'browserName' => 'firefox',

docs/examples/getting-started/cloud_selenium_configs.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ class BrowserConfigExampleTest extends BrowserTestCase
99
// Sauce Labs browser configuration.
1010
array(
1111
'type' => 'saucelabs',
12-
'api_username' => '...',
13-
'api_key' => '...',
12+
'apiUsername' => '...',
13+
'apiKey' => '...',
1414
'browserName' => 'firefox',
1515
'baseUrl' => 'http://www.google.com',
1616
),
@@ -24,6 +24,7 @@ class BrowserConfigExampleTest extends BrowserTestCase
2424
),
2525
// Regular browser configuration.
2626
array(
27+
'driver' => 'selenium2',
2728
'host' => 'localhost',
2829
'port' => 4444,
2930
'browserName' => 'chrome',

docs/examples/getting-started/general_test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class GeneralTest extends BrowserTestCase
77

88
public static $browsers = array(
99
array(
10+
'driver' => 'selenium2',
1011
'host' => 'localhost',
1112
'port' => 4444,
1213
'browserName' => 'firefox',

0 commit comments

Comments
 (0)