Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mink driver selection ability in configuration #49

Merged
merged 2 commits into from
Mar 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

"require": {
"php": ">=5.3.2",
"behat/mink": "~1.6",
"behat/mink": "~1.6@dev",
"behat/mink-selenium2-driver": "~1.2",
"symfony/event-dispatcher": "~2.4",
"pimple/pimple": "~2.0|~3.0",
Expand Down
60 changes: 34 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 23 additions & 12 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ configuration) in that test case class.

.. literalinclude:: examples/configuration/config_via_browsers_property.php
:linenos:
:emphasize-lines: 8,9,15
:emphasize-lines: 8,9,16

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

.. literalinclude:: examples/configuration/per_test_case_browser_config.php
:linenos:
:emphasize-lines: 14
:emphasize-lines: 15

Selecting the Mink Driver
^^^^^^^^^^^^^^^^^^^^^^^^^
With the help of ``driver`` and ``driverOptions`` browser configuration settings (since v2.1.0) it's possible to
specify which `Mink`_ driver to use. This file demonstrates how to use each driver:

.. literalinclude:: examples/configuration/driver_showcase.php
:linenos:
:emphasize-lines: 10,20,32,40

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

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

There are also corresponding setters (e.g. ``setHost``) and getters (e.g. ``getHost``) for each of mentioned
above settings, that allow to individually change them from ``setUp`` method before test has started.
Expand Down
1 change: 1 addition & 0 deletions docs/examples/browser_aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public function getBrowserAliases()
{
return array(
'example_alias' => array(
'driver' => 'selenium2',
'host' => 'localhost',
'port' => 4444,
'browserName' => 'firefox',
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/configuration/config_via_browsers_property.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ class PerTestCaseBrowserConfigTest extends BrowserTestCase

public static $browsers = array(
array(
'driver' => 'selenium2',
'host' => 'localhost',
'port' => 4444,
'browserName' => 'firefox',
'baseUrl' => 'http://www.google.com',
),
array(
'driver' => 'selenium2',
'host' => 'localhost',
'port' => 4444,
'browserName' => 'chrome',
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/configuration/config_via_setup_method.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ protected function setUp()
$browser = $this->createBrowserConfiguration(array(
// required
'type' => 'saucelabs',
'api_username' => 'sauce_username',
'api_key' => 'sauce_api_key',
'apiUsername' => 'sauce_username',
'apiKey' => 'sauce_api_key',
// optional options goes here
));

Expand Down
53 changes: 53 additions & 0 deletions docs/examples/configuration/driver_showcase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

use aik099\PHPUnit\BrowserTestCase;

class DriverShowCaseTest extends BrowserTestCase
{

public static $browsers = array(
array(
'driver' => 'goutte',

// Defaults for this driver.
'driverOptions' => array(
'server_parameters' => array(),
'guzzle_parameters' => array(),
),

),
array(
'driver' => 'sahi',

// Defaults for this driver.
'port' => 9999,
'driverOptions' => array(
'sid' => null,
'limit' => 600,
'browser' => null,
),
),

array(
'driver' => 'selenium2',

// Defaults for this driver.
'port' => 4444,
'driverOptions' => array(),
),

array(
'driver' => 'zombie',

// Defaults for this driver.
'port' => 8124,
'driverOptions' => array(
'node_bin' => 'node',
'server_path' => null,
'threshold' => 2000000,
'node_modules_path' => '',
),
),
);

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CommonBrowserConfigTest extends BrowserTestCase

public static $browsers = array(
array(
'driver' => 'selenium2',
'host' => 'localhost',
'port' => 4444,
'browserName' => 'firefox',
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/getting-started/cloud_selenium_configs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class BrowserConfigExampleTest extends BrowserTestCase
// Sauce Labs browser configuration.
array(
'type' => 'saucelabs',
'api_username' => '...',
'api_key' => '...',
'apiUsername' => '...',
'apiKey' => '...',
'browserName' => 'firefox',
'baseUrl' => 'http://www.google.com',
),
Expand All @@ -24,6 +24,7 @@ class BrowserConfigExampleTest extends BrowserTestCase
),
// Regular browser configuration.
array(
'driver' => 'selenium2',
'host' => 'localhost',
'port' => 4444,
'browserName' => 'chrome',
Expand Down
1 change: 1 addition & 0 deletions docs/examples/getting-started/general_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class GeneralTest extends BrowserTestCase

public static $browsers = array(
array(
'driver' => 'selenium2',
'host' => 'localhost',
'port' => 4444,
'browserName' => 'firefox',
Expand Down
6 changes: 3 additions & 3 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ Basic Usage

.. literalinclude:: examples/getting-started/general_test.php
:linenos:
:emphasize-lines: 5,8,20,34
:emphasize-lines: 5,8,21,35

Selenium in Cloud
^^^^^^^^^^^^^^^^^
When using Selenium-based solution for automated testing in the cloud (e.g. `Sauce Labs`_ or `BrowserStack`_) you need to
specify following settings:

* ``'type' => 'saucelabs'`` or ``'type' => 'browserstack'``
* ``'api_username' => '...'``
* ``'api_key' => '...'``
* ``'apiUsername' => '...'``
* ``'apiKey' => '...'``

instead of ``host`` and ``port`` settings. In all other aspects everything will work the same as if all
tests were running locally.
Expand Down
Loading