Skip to content

Commit 384bae4

Browse files
authored
Merge pull request #138 from aik099/webdriver-classic-support
Added support for WebdriverClassicDriver Mink's Driver
2 parents e6b575b + 0dead48 commit 384bae4

7 files changed

Lines changed: 93 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [Unreleased]
66
### Added
7-
...
7+
- Added support for WebdriverClassicDriver Mink's Driver (supports Selenium 2, 3, 4) as `webdriver-classic`.
88

99
### Changed
1010
...

docs/examples/configuration/driver_showcase.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ class DriverShowCaseTest extends BrowserTestCase
3636
'driverOptions' => array(),
3737
),
3838

39+
array(
40+
'driver' => 'webdriver-classic',
41+
42+
// Defaults for this driver.
43+
'port' => 4444,
44+
'driverOptions' => array(),
45+
),
46+
3947
array(
4048
'driver' => 'zombie',
4149

library/aik099/PHPUnit/BrowserConfiguration/BrowserConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BrowserConfiguration
4747
'driver' => 'selenium2',
4848
'driverOptions' => array(),
4949

50-
// TODO: Move under 'driverOptions' of 'selenium2' driver (BC break).
50+
// TODO: Move under 'driverOptions' of 'selenium2'/'webdriver-classic' driver (BC break).
5151
'desiredCapabilities' => array(),
5252
'timeout' => 60,
5353

library/aik099/PHPUnit/DIContainer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use aik099\PHPUnit\MinkDriver\GoutteDriverFactory;
2121
use aik099\PHPUnit\MinkDriver\SahiDriverFactory;
2222
use aik099\PHPUnit\MinkDriver\Selenium2DriverFactory;
23+
use aik099\PHPUnit\MinkDriver\WebdriverClassicFactory;
2324
use aik099\PHPUnit\MinkDriver\ZombieDriverFactory;
2425
use aik099\PHPUnit\RemoteCoverage\RemoteCoverageHelper;
2526
use aik099\PHPUnit\RemoteCoverage\RemoteUrl;
@@ -112,6 +113,7 @@ public function __construct(array $values = array())
112113
$registry = new DriverFactoryRegistry();
113114

114115
$registry->add(new Selenium2DriverFactory());
116+
$registry->add(new WebdriverClassicFactory());
115117
$registry->add(new SahiDriverFactory());
116118
$registry->add(new GoutteDriverFactory());
117119
$registry->add(new ZombieDriverFactory());
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/**
3+
* This file is part of the phpunit-mink library.
4+
* For the full copyright and license information, please view
5+
* the LICENSE file that was distributed with this source code.
6+
*
7+
* @copyright Alexander Obuhovich <aik.bold@gmail.com>
8+
* @link https://github.com/aik099/phpunit-mink
9+
*/
10+
11+
12+
namespace aik099\PHPUnit\MinkDriver;
13+
14+
15+
use aik099\PHPUnit\BrowserConfiguration\BrowserConfiguration;
16+
17+
class WebdriverClassicFactory extends AbstractDriverFactory
18+
{
19+
20+
/**
21+
* Returns driver name, that can be used in browser configuration.
22+
*
23+
* @return string
24+
*/
25+
public function getDriverName()
26+
{
27+
return 'webdriver-classic';
28+
}
29+
30+
/**
31+
* @inheritDoc
32+
*/
33+
public function getDriverPackageUrl()
34+
{
35+
return 'https://packagist.org/packages/mink/webdriver-classic-driver';
36+
}
37+
38+
/**
39+
* Returns default values for browser configuration.
40+
*
41+
* @return array
42+
*/
43+
public function getDriverDefaults()
44+
{
45+
return array(
46+
'port' => 4444,
47+
'driverOptions' => array(),
48+
);
49+
}
50+
51+
/**
52+
* @inheritDoc
53+
*/
54+
public function createDriver(BrowserConfiguration $browser)
55+
{
56+
$this->assertInstalled('Mink\WebdriverClassicDriver\WebdriverClassicDriver');
57+
58+
$browser_name = $browser->getBrowserName();
59+
$capabilities = $browser->getDesiredCapabilities();
60+
$capabilities['browserName'] = $browser_name;
61+
62+
// TODO: Maybe doesn't work!
63+
ini_set('default_socket_timeout', $browser->getTimeout());
64+
65+
$driver = new \Mink\WebdriverClassicDriver\WebdriverClassicDriver(
66+
$browser_name,
67+
$capabilities,
68+
'http://' . $browser->getHost() . ':' . $browser->getPort() . '/wd/hub'
69+
);
70+
71+
return $driver;
72+
}
73+
74+
}

tests/aik099/PHPUnit/Integration/DIContainerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use aik099\PHPUnit\MinkDriver\GoutteDriverFactory;
2424
use aik099\PHPUnit\MinkDriver\SahiDriverFactory;
2525
use aik099\PHPUnit\MinkDriver\Selenium2DriverFactory;
26+
use aik099\PHPUnit\MinkDriver\WebdriverClassicFactory;
2627
use aik099\PHPUnit\MinkDriver\ZombieDriverFactory;
2728
use aik099\PHPUnit\RemoteCoverage\RemoteCoverageHelper;
2829
use aik099\PHPUnit\RemoteCoverage\RemoteUrl;
@@ -116,6 +117,7 @@ public function testDriverFactoryRegistry()
116117
$driver_factory_registry = $this->_container['driver_factory_registry'];
117118

118119
$this->assertInstanceOf(Selenium2DriverFactory::class, $driver_factory_registry->get('selenium2'));
120+
$this->assertInstanceOf(WebdriverClassicFactory::class, $driver_factory_registry->get('webdriver-classic'));
119121
$this->assertInstanceOf(SahiDriverFactory::class, $driver_factory_registry->get('sahi'));
120122
$this->assertInstanceOf(GoutteDriverFactory::class, $driver_factory_registry->get('goutte'));
121123
$this->assertInstanceOf(ZombieDriverFactory::class, $driver_factory_registry->get('zombie'));

tests/aik099/PHPUnit/MinkDriver/DriverFactoryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use aik099\PHPUnit\BrowserConfiguration\BrowserConfiguration;
1616
use aik099\PHPUnit\DIContainer;
1717
use aik099\PHPUnit\MinkDriver\IMinkDriverFactory;
18+
use aik099\PHPUnit\MinkDriver\WebdriverClassicFactory;
1819
use tests\aik099\PHPUnit\AbstractTestCase;
1920
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
2021
use aik099\PHPUnit\MinkDriver\GoutteDriverFactory;
@@ -97,6 +98,10 @@ public static function driverDataProvider()
9798
'\Behat\Mink\Driver\Selenium2Driver',
9899
Selenium2DriverFactory::class,
99100
),
101+
'webdriver-classic' => array(
102+
'\Mink\WebdriverClassicDriver\WebdriverClassicDriver',
103+
WebdriverClassicFactory::class,
104+
),
100105
'zombie' => array(
101106
'\Behat\Mink\Driver\ZombieDriver',
102107
ZombieDriverFactory::class,

0 commit comments

Comments
 (0)