Skip to content

Commit

Permalink
Merge pull request #138 from aik099/webdriver-classic-support
Browse files Browse the repository at this point in the history
Added support for WebdriverClassicDriver Mink's Driver
  • Loading branch information
aik099 authored Oct 31, 2024
2 parents e6b575b + 0dead48 commit 384bae4
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

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

### Changed
...
Expand Down
8 changes: 8 additions & 0 deletions docs/examples/configuration/driver_showcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class DriverShowCaseTest extends BrowserTestCase
'driverOptions' => array(),
),

array(
'driver' => 'webdriver-classic',

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

array(
'driver' => 'zombie',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class BrowserConfiguration
'driver' => 'selenium2',
'driverOptions' => array(),

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

Expand Down
2 changes: 2 additions & 0 deletions library/aik099/PHPUnit/DIContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use aik099\PHPUnit\MinkDriver\GoutteDriverFactory;
use aik099\PHPUnit\MinkDriver\SahiDriverFactory;
use aik099\PHPUnit\MinkDriver\Selenium2DriverFactory;
use aik099\PHPUnit\MinkDriver\WebdriverClassicFactory;
use aik099\PHPUnit\MinkDriver\ZombieDriverFactory;
use aik099\PHPUnit\RemoteCoverage\RemoteCoverageHelper;
use aik099\PHPUnit\RemoteCoverage\RemoteUrl;
Expand Down Expand Up @@ -112,6 +113,7 @@ public function __construct(array $values = array())
$registry = new DriverFactoryRegistry();

$registry->add(new Selenium2DriverFactory());
$registry->add(new WebdriverClassicFactory());
$registry->add(new SahiDriverFactory());
$registry->add(new GoutteDriverFactory());
$registry->add(new ZombieDriverFactory());
Expand Down
74 changes: 74 additions & 0 deletions library/aik099/PHPUnit/MinkDriver/WebdriverClassicFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/**
* This file is part of the phpunit-mink library.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @copyright Alexander Obuhovich <[email protected]>
* @link https://github.com/aik099/phpunit-mink
*/


namespace aik099\PHPUnit\MinkDriver;


use aik099\PHPUnit\BrowserConfiguration\BrowserConfiguration;

class WebdriverClassicFactory extends AbstractDriverFactory
{

/**
* Returns driver name, that can be used in browser configuration.
*
* @return string
*/
public function getDriverName()
{
return 'webdriver-classic';
}

/**
* @inheritDoc
*/
public function getDriverPackageUrl()
{
return 'https://packagist.org/packages/mink/webdriver-classic-driver';
}

/**
* Returns default values for browser configuration.
*
* @return array
*/
public function getDriverDefaults()
{
return array(
'port' => 4444,
'driverOptions' => array(),
);
}

/**
* @inheritDoc
*/
public function createDriver(BrowserConfiguration $browser)
{
$this->assertInstalled('Mink\WebdriverClassicDriver\WebdriverClassicDriver');

$browser_name = $browser->getBrowserName();
$capabilities = $browser->getDesiredCapabilities();
$capabilities['browserName'] = $browser_name;

// TODO: Maybe doesn't work!
ini_set('default_socket_timeout', $browser->getTimeout());

$driver = new \Mink\WebdriverClassicDriver\WebdriverClassicDriver(
$browser_name,
$capabilities,
'http://' . $browser->getHost() . ':' . $browser->getPort() . '/wd/hub'
);

return $driver;
}

}
2 changes: 2 additions & 0 deletions tests/aik099/PHPUnit/Integration/DIContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use aik099\PHPUnit\MinkDriver\GoutteDriverFactory;
use aik099\PHPUnit\MinkDriver\SahiDriverFactory;
use aik099\PHPUnit\MinkDriver\Selenium2DriverFactory;
use aik099\PHPUnit\MinkDriver\WebdriverClassicFactory;
use aik099\PHPUnit\MinkDriver\ZombieDriverFactory;
use aik099\PHPUnit\RemoteCoverage\RemoteCoverageHelper;
use aik099\PHPUnit\RemoteCoverage\RemoteUrl;
Expand Down Expand Up @@ -116,6 +117,7 @@ public function testDriverFactoryRegistry()
$driver_factory_registry = $this->_container['driver_factory_registry'];

$this->assertInstanceOf(Selenium2DriverFactory::class, $driver_factory_registry->get('selenium2'));
$this->assertInstanceOf(WebdriverClassicFactory::class, $driver_factory_registry->get('webdriver-classic'));
$this->assertInstanceOf(SahiDriverFactory::class, $driver_factory_registry->get('sahi'));
$this->assertInstanceOf(GoutteDriverFactory::class, $driver_factory_registry->get('goutte'));
$this->assertInstanceOf(ZombieDriverFactory::class, $driver_factory_registry->get('zombie'));
Expand Down
5 changes: 5 additions & 0 deletions tests/aik099/PHPUnit/MinkDriver/DriverFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use aik099\PHPUnit\BrowserConfiguration\BrowserConfiguration;
use aik099\PHPUnit\DIContainer;
use aik099\PHPUnit\MinkDriver\IMinkDriverFactory;
use aik099\PHPUnit\MinkDriver\WebdriverClassicFactory;
use tests\aik099\PHPUnit\AbstractTestCase;
use Yoast\PHPUnitPolyfills\Polyfills\ExpectException;
use aik099\PHPUnit\MinkDriver\GoutteDriverFactory;
Expand Down Expand Up @@ -97,6 +98,10 @@ public static function driverDataProvider()
'\Behat\Mink\Driver\Selenium2Driver',
Selenium2DriverFactory::class,
),
'webdriver-classic' => array(
'\Mink\WebdriverClassicDriver\WebdriverClassicDriver',
WebdriverClassicFactory::class,
),
'zombie' => array(
'\Behat\Mink\Driver\ZombieDriver',
ZombieDriverFactory::class,
Expand Down

0 comments on commit 384bae4

Please sign in to comment.