diff --git a/src/WebdriverClassicDriver.php b/src/WebdriverClassicDriver.php index e185940..438abd5 100644 --- a/src/WebdriverClassicDriver.php +++ b/src/WebdriverClassicDriver.php @@ -961,6 +961,14 @@ private function applyTimeouts(): void $timeouts->implicitlyWait($param / 1000); break; + case 'page load': + case 'pageLoad': + @trigger_error( + "Using \"$type\" timeout type is deprecated, please use \"page\" instead", + E_USER_DEPRECATED + ); + // no break + case 'page': $timeouts->pageLoadTimeout($param / 1000); break; diff --git a/tests/Custom/TestCase.php b/tests/Custom/TestCase.php index c8fb543..c5a521f 100644 --- a/tests/Custom/TestCase.php +++ b/tests/Custom/TestCase.php @@ -43,7 +43,7 @@ protected function getConfig(): WebdriverClassicConfig */ protected function checkSkippedTest(): void { - $message = self::getConfig()->skipMessage(get_class($this), $this->getName(false)); + $message = $this->getConfig()->skipMessage(static::class, $this->getName(false)); if (null !== $message) { $this->markTestSkipped($message); diff --git a/tests/Custom/TimeoutTest.php b/tests/Custom/TimeoutTest.php index f0c1914..b8c49e9 100644 --- a/tests/Custom/TimeoutTest.php +++ b/tests/Custom/TimeoutTest.php @@ -6,17 +6,6 @@ class TimeoutTest extends TestCase { - protected function tearDown(): void - { - $this->driver->setTimeouts([ - 'script' => 30000, - 'page' => 300000, - 'implicit' => 0, - ]); - - parent::tearDown(); - } - public function testInvalidTimeoutSettingThrowsException(): void { $this->driver->start(); @@ -59,4 +48,26 @@ public function testShortPageLoadTimeoutThrowsException(): void $this->driver->visit($this->pathTo('/page_load.php?sleep=2')); } + + /** + * @group legacy + * @dataProvider deprecatedPageLoadDataProvider + */ + public function testDeprecatedShortPageLoadTimeoutThrowsException(string $type): void + { + $this->driver->start(); + + $this->expectDeprecation('Using "' . $type . '" timeout type is deprecated, please use "page" instead'); + $this->driver->setTimeouts([$type => 500]); + + $this->expectException(DriverException::class); + $this->expectExceptionMessage('Page failed to load: '); + $this->driver->visit($this->pathTo('/page_load.php?sleep=2')); + } + + public static function deprecatedPageLoadDataProvider(): iterable + { + yield 'selenium 3 style' => ['type' => 'pageLoad']; + yield 'selenium 2 style' => ['type' => 'page load']; + } } diff --git a/tests/WebdriverClassicConfig.php b/tests/WebdriverClassicConfig.php index d293071..f3d19bd 100644 --- a/tests/WebdriverClassicConfig.php +++ b/tests/WebdriverClassicConfig.php @@ -7,7 +7,9 @@ use Behat\Mink\Tests\Driver\Basic\HeaderTest; use Behat\Mink\Tests\Driver\Basic\StatusCodeTest; use Behat\Mink\Tests\Driver\Js\EventsTest; +use Behat\Mink\Tests\Driver\Js\JavascriptTest; use Behat\Mink\Tests\Driver\Js\WindowTest; +use Mink\WebdriverClassicDriver\Tests\Custom\TimeoutTest; use Mink\WebdriverClassicDriver\WebdriverClassicDriver; class WebdriverClassicConfig extends AbstractConfig @@ -43,7 +45,8 @@ public function mapRemoteFilePath($file): string public function skipMessage($testCase, $test): ?string { switch (true) { - case $testCase === WindowTest::class && $test === 'testWindowMaximize' && $this->isXvfb(): + case [$testCase, $test] === [WindowTest::class, 'testWindowMaximize'] + && $this->isXvfb(): return 'Maximizing the window does not work when running the browser in Xvfb.'; case $testCase === BasicAuthTest::class: @@ -55,17 +58,24 @@ public function skipMessage($testCase, $test): ?string case $testCase === StatusCodeTest::class: return 'Checking status code is not supported.'; - case $testCase === EventsTest::class && $test === 'testKeyboardEvents' && $this->isOldChrome(): + case [$testCase, $test] === [EventsTest::class, 'testKeyboardEvents'] + && $this->isOldChrome(): return 'Old Chrome does not allow triggering events.'; + case [$testCase, $test] === [TimeoutTest::class, 'testDeprecatedShortPageLoadTimeoutThrowsException'] + && ($this->isChromiumBased() || $this->isOldFirefox()) + && $this->isXvfb(): + return 'Setting page load timeout several times causes a freeze in this browser.'; + + case [$testCase, $test] === [JavascriptTest::class, 'testDragDropOntoHiddenItself'] + && $this->isOldFirefox(): + return 'The Firefox browser compatible with Selenium Server 2.x does not fully implement drag-n-drop support.'; + default: return parent::skipMessage($testCase, $test); } } - /** - * {@inheritdoc} - */ protected function supportsCss(): bool { return true; @@ -81,4 +91,15 @@ private function isOldChrome(): bool return getenv('WEB_FIXTURES_BROWSER') === 'chrome' && version_compare(getenv('SELENIUM_VERSION') ?: '', '3', '<'); } + + private function isOldFirefox(): bool + { + return getenv('WEB_FIXTURES_BROWSER') === 'firefox' + && version_compare(getenv('SELENIUM_VERSION') ?: '', '3', '<'); + } + + private function isChromiumBased(): bool + { + return in_array($this->getBrowserName(), ['chrome', 'chromium', 'edge']); + } }