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

Support MinkSelenium2Driver page timeout #38

Merged
merged 49 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
ae36f04
Support MinkSelenium2Driver page timeout
uuf6429 Nov 2, 2024
09beee0
Trigger deprecation of old-style page timeout
uuf6429 Nov 2, 2024
6aefa43
Replace duplicate code with comment
uuf6429 Nov 2, 2024
fd1b1c6
Test deprecations
uuf6429 Nov 3, 2024
999217a
Rework custom tests to not depend on magic setup
uuf6429 Nov 3, 2024
28c64b1
Set up standard defaults to avoid contaminated sessions
uuf6429 Nov 3, 2024
037cffa
[debug] Only run tests that fail
aik099 Nov 4, 2024
eda6ffa
[debug] Adjusted PHPUnit 10 test filtering expression to work on PHPU…
aik099 Nov 4, 2024
f6b3bfd
[debug] remove irrelevant (for debugging) build config sections to sp…
aik099 Nov 4, 2024
2b9ecbe
[debug] Reduce matrix size even more
aik099 Nov 4, 2024
8397a6c
Don't let driver define Selenium Server default timeouts
aik099 Nov 4, 2024
659b752
[debug] confirm, that timeout tests executed at the beginning would b…
aik099 Nov 4, 2024
dca90b4
Revert "[debug] confirm, that timeout tests executed at the beginning…
aik099 Nov 4, 2024
ef3c21e
[debug] see if Selenium actually sets timeouts as needed
aik099 Nov 4, 2024
ece5bc5
Don't reset timeout at the test end, because new driver instance is c…
aik099 Nov 4, 2024
d39e277
[debug] PhpStan fix
aik099 Nov 4, 2024
7d156ee
[debug] see if session with incorrect timeout is shared between tests
aik099 Nov 4, 2024
3a173a4
Fixed formatting error
aik099 Nov 4, 2024
bfba3fe
[debug] see if deprecation catching causes timeout issues
aik099 Nov 4, 2024
b4d27e9
[debug] see of sleepy page causes a timeout issue
aik099 Nov 4, 2024
8e56504
[debug] change data provider declaration of the timeouts test
aik099 Nov 4, 2024
a2ec19e
[debug] removed debug output in the driver code, because not timeouts…
aik099 Nov 4, 2024
058fb96
[debug] Look inside GitHub Actions with an SSH session
aik099 Nov 4, 2024
ca8438b
[debug] start web server outside of PHPUnit bootstrap file
aik099 Nov 4, 2024
40fc14b
[debug] remove unrelated build config parts
aik099 Nov 4, 2024
8f3b2f0
[debug] corrected host of locally started mink server
aik099 Nov 4, 2024
14d883d
[debug] corrected hostname for started web server checking
aik099 Nov 4, 2024
3d89a73
[debug] another try to get local web server running
aik099 Nov 4, 2024
e16ab3b
[debug] reduce test count to figure out why web server is not working
aik099 Nov 4, 2024
371a427
[debug] Experiment with WEB_FIXTURES_HOST env var detection
aik099 Nov 4, 2024
5ad37be
[debug] another try to debug what URL is actually used by test suite
aik099 Nov 4, 2024
79fb097
[debug] another try
aik099 Nov 4, 2024
83d213b
Allow overriding env vars from "phpunit.xml.dist" via env vars from G…
aik099 Nov 4, 2024
6c26545
[debug] removed some of the debug code
aik099 Nov 4, 2024
e226ded
[debug] change local web server detection code to avoid it's crashing…
aik099 Nov 4, 2024
d0ab103
[debug] try to make web server available for Selenium Server
aik099 Nov 4, 2024
dfa02dd
[debug] undo experimental port mapping
aik099 Nov 4, 2024
f3cd1a9
[debug] attempt to start web sever on all ips
aik099 Nov 4, 2024
5a7e0b2
[debug] rolled back CI code that reduced build count
aik099 Nov 4, 2024
b15e2bf
[debug] rolled back the debug code, that started web server outside o…
aik099 Nov 4, 2024
0988e77
rolled back changes to "phpunit.xml.dist" (to be discussed in other i…
aik099 Nov 5, 2024
4a860d2
Partially skip short "pageLoad" timeout test in Google Chrome
aik099 Nov 11, 2024
5fa8241
Fully skip short "pageLoad" timeout test in Google Chrome
aik099 Nov 11, 2024
409a243
Only skip test added in this PR for Google Chrome
aik099 Nov 11, 2024
bae768e
Apparently "chromium" and "edge" browsers also freeze, when setting "…
aik099 Nov 11, 2024
2c6a20c
Exclude timeout deprecation test only on GitHub Actions
aik099 Nov 12, 2024
e384d12
Minor test fixes and improvements
uuf6429 Nov 12, 2024
d2165ab
Disable test on old firefox
uuf6429 Nov 12, 2024
2da66a7
Fix minkphp/MinkSelenium2Driver#391
uuf6429 Nov 12, 2024
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
8 changes: 8 additions & 0 deletions src/WebdriverClassicDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,14 @@
$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
);

Check warning on line 969 in src/WebdriverClassicDriver.php

View check run for this annotation

Codecov / codecov/patch

src/WebdriverClassicDriver.php#L966-L969

Added lines #L966 - L969 were not covered by tests
uuf6429 marked this conversation as resolved.
Show resolved Hide resolved
// no break

case 'page':
$timeouts->pageLoadTimeout($param / 1000);
break;
Expand Down
2 changes: 1 addition & 1 deletion tests/Custom/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 22 additions & 11 deletions tests/Custom/TimeoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -59,4 +48,26 @@ public function testShortPageLoadTimeoutThrowsException(): void

$this->driver->visit($this->pathTo('/page_load.php?sleep=2'));
}

/**
* @group legacy
uuf6429 marked this conversation as resolved.
Show resolved Hide resolved
* @dataProvider deprecatedPageLoadDataProvider
*/
public function testDeprecatedShortPageLoadTimeoutThrowsException(string $type): void
{
$this->driver->start();

$this->expectDeprecation('Using "' . $type . '" timeout type is deprecated, please use "page" instead');
uuf6429 marked this conversation as resolved.
Show resolved Hide resolved
$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'];
}
}
31 changes: 26 additions & 5 deletions tests/WebdriverClassicConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand All @@ -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']);
}
}