Skip to content
Open
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
14 changes: 8 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
<php>
<var name="driver_config_factory" value="Behat\Mink\Tests\Driver\Selenium2Config::getInstance" />

<!--server name="WEB_FIXTURES_HOST" value="http://test.mink.dev" /-->
<!--<env name="SELENIUM_VERSION" value="3" />-->

<!--<env name="WEB_FIXTURES_HOST" value="http://test.mink.dev" />-->
<!-- MacOS -->
<!--<server name="WEB_FIXTURES_HOST" value="http://docker.for.mac.localhost:8002"/>-->
<!--<env name="WEB_FIXTURES_HOST" value="http://docker.for.mac.localhost:8002" />-->

<!--<server name="WEB_FIXTURES_BROWSER" value="firefox"/>-->
<env name="WEB_FIXTURES_BROWSER" value="firefox" />

<!-- where driver will connect to -->
<server name="DRIVER_URL" value="http://localhost:4444/wd/hub" />
<env name="DRIVER_URL" value="http://localhost:4444/wd/hub" />

<!-- where DocumentRoot of 'Test Machine' is mounted to on 'Driver Machine' (only if these are 2 different machines) -->
<!--server name="DRIVER_MACHINE_BASE_PATH" value="" /-->
<!--server name="TEST_MACHINE_BASE_PATH" value="" /-->
<!--<env name="DRIVER_MACHINE_BASE_PATH" value="" />-->
<!--<env name="TEST_MACHINE_BASE_PATH" value="" />-->
</php>

<filter>
Expand Down
21 changes: 14 additions & 7 deletions tests/Selenium2Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Selenium2Config extends AbstractConfig

public function __construct()
{
$this->seleniumMajorVersion = (int) explode('.', $_SERVER['SELENIUM_VERSION'] ?? '')[0];
$this->seleniumMajorVersion = (int) explode('.', $this->getEnvVar('SELENIUM_VERSION') ?? '')[0];
}

public static function getInstance(): self
Expand All @@ -34,17 +34,24 @@ public static function getInstance(): self

public function createDriver(): DriverInterface
{
$browser = getenv('WEB_FIXTURES_BROWSER') ?: 'firefox';
$seleniumHost = $_SERVER['DRIVER_URL'];
$browser = $this->getBrowserName();
$seleniumHost = $this->getEnvVar('DRIVER_URL') ?? 'http://localhost:4444/wd/hub';

return new Selenium2Driver($browser, null, $seleniumHost);
}

public function getBrowserName(): string
{
return $this->getEnvVar('WEB_FIXTURES_BROWSER') ?? 'firefox';
}

public function mapRemoteFilePath($file): string
{
if (!isset($_SERVER['TEST_MACHINE_BASE_PATH'])) {
// Auto-detect "TEST_MACHINE_BASE_PATH" from the test fixtures folder location, so only "DRIVER_MACHINE_BASE_PATH"
// has to be set, when only this folder is shared with the Selenium machine (e.g. "/fixtures/" in "docker-compose.yml").
if (null === $this->getEnvVar('TEST_MACHINE_BASE_PATH')) {
$webFixturesPath = dirname(__DIR__) . '/vendor/mink/driver-testsuite/web-fixtures';
$_SERVER['TEST_MACHINE_BASE_PATH'] = realpath($webFixturesPath) . DIRECTORY_SEPARATOR;
putenv('TEST_MACHINE_BASE_PATH=' . realpath($webFixturesPath) . DIRECTORY_SEPARATOR);
}

return parent::mapRemoteFilePath($file);
Expand Down Expand Up @@ -82,15 +89,15 @@ public function skipMessage($testCase, $test): ?string
}

if (array(JavascriptTest::class, 'testDragDropOntoHiddenItself') === $testCallback) {
$browser = $_SERVER['WEB_FIXTURES_BROWSER'] ?? null;
$browser = $this->getBrowserName();

if ($browser === 'firefox' && $this->getSeleniumMajorVersion() === 2) {
return 'The Firefox browser compatible with Selenium 2.x does not fully implement drag-n-drop support.';
}
}

if (array(EventsTest::class, 'testKeyboardEvents') === $testCallback) {
$browser = $_SERVER['WEB_FIXTURES_BROWSER'] ?? null;
$browser = $this->getBrowserName();

if ($browser === 'chrome' && $this->getSeleniumMajorVersion() === 2) {
return 'The Chrome browser compatible with Selenium 2.x ignores key codes in synthetic keyboard events.';
Expand Down
Loading