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

feat: add PANTHER_REDUCED_MOTION to limit animations #651

Merged
merged 5 commits into from
Jan 8, 2025

Conversation

Jean-Beru
Copy link
Contributor

This PR add a PANTHER_REDUCED_MOTION environment variable to set the prefers-reduced-motion CSS media feature to reduce.

It could be useful to limit "flaky" tests which result in a Facebook\WebDriver\Exception\ElementClickInterceptedException: Element <XXX> is not clickable at point (XXX, YYY) because another element XXX obscures it exception because an animation is still in progress.

This CSS media feature is already supported by Bootstrap or the french DSFR.

@Jean-Beru Jean-Beru force-pushed the add-reduced-motion branch 4 times, most recently from 0d04f2a to 83527aa Compare December 10, 2024 16:28
Copy link
Member

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! We should even enable this by default.

@@ -114,6 +114,11 @@ private function getDefaultArguments(): array
$args[] = '--no-sandbox';
}

// Prefer reduced motion, see https://developer.mozilla.org/fr/docs/Web/CSS/@media/prefers-reduced-motion
if ($_SERVER['PANTHER_REDUCED_MOTION'] ?? false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($_SERVER['PANTHER_REDUCED_MOTION'] ?? false) {
if (filter_var($_SERVER['PANTHER_REDUCED_MOTION'] ?? true, \FILTER_VALIDATE_BOOLEAN)) {

(see #632)

@@ -63,6 +64,14 @@ public function start(): WebDriver
$capabilities = DesiredCapabilities::firefox();
$capabilities->setCapability('moz:firefoxOptions', $firefoxOptions);

// Prefer reduced motion, see https://developer.mozilla.org/fr/docs/Web/CSS/@media/prefers-reduced-motion
if ($_SERVER['PANTHER_REDUCED_MOTION'] ?? false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($_SERVER['PANTHER_REDUCED_MOTION'] ?? false) {
if (filter_var($_SERVER['PANTHER_REDUCED_MOTION'] ?? true, \FILTER_VALIDATE_BOOLEAN)) {

@Jean-Beru
Copy link
Contributor Author

Good idea! We should even enable this by default.

I totally agree 🙂

@dunglas
Copy link
Member

dunglas commented Jan 8, 2025

Maybe make this config the default and introduce a PANTHER_NO_REDUCED_MOTION to disable it then?

@Jean-Beru
Copy link
Contributor Author

Jean-Beru commented Jan 8, 2025

It makes sense with PANTHER_NO_HEADLESS 👍

I also added a test (and fixed a bug spotted by it).

src/ProcessManager/ChromeManager.php Outdated Show resolved Hide resolved
@dunglas
Copy link
Member

dunglas commented Jan 8, 2025

Thank you!

@Jean-Beru
Copy link
Contributor Author

@dunglas FYI, I'm trying to understand why https://github.com/symfony/panther/actions/runs/12673280007/job/35319306027?pr=651 is failing

@dunglas dunglas merged commit 1e8718e into symfony:main Jan 8, 2025
16 of 19 checks passed
@dunglas
Copy link
Member

dunglas commented Jan 8, 2025

Thanks!

@Jean-Beru Jean-Beru deleted the add-reduced-motion branch January 8, 2025 15:45
@Jean-Beru Jean-Beru restored the add-reduced-motion branch January 8, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants