Symfony 4.4 PHPUnit Panther : Facebook\WebDriver\Exception\SessionNotCreatedException: session not created

951 views Asked by At

Here is my test file:

<?php
// src/tests/UserActionsTest.php
namespace App\Tests;
 
use Symfony\Component\Panther\PantherTestCase;
 
class UserActionsTest extends PantherTestCase {
    /**
     * An user can subscribe on the Blog
     */
    public function testRegistration(): void {
        $client = static::createPantherClient();
        $crawler = $client->request('GET', '/subscribe');
 
        // This form is generated in JavaScript
        $client->waitFor('#subscribe-form');
 
        // Form submission
        $client->submitForm('Create the account', [
            'username' => 'zozor',
            'password' => 'ZoZ0rIsHome',
        ]);
 
        // User rediction newly subscribed to the homepage
        $this->assertSame(self::$baseUrl . '/', $client->getCurrentURL());
 
        // Success notification in JavaScript
        $client->waitFor('#success-message');
        $this->assertSame('Welcome on the Zozor blog', $crawler->filter('#success-message ol li:first-child')->text());
 
        // The user is well authenticatd
        $this->assertSame('Zozor', $crawler->filter('#user-profile span:first-child')->text());
    }
}

When I run the command:

PANTHER_NO_HEADLESS=1 ./vendor/bin/simple-phpunit --filter="UserActionsTest"

This gives me an error:

1) App\Tests\UserActionsTest::testRegistration
Facebook\WebDriver\Exception\SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 85
 
./vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:125
./vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:371
./vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:136
./vendor/symfony/panther/src/ProcessManager/ChromeManager.php:67
./vendor/symfony/panther/src/Client.php:98
./vendor/symfony/panther/src/Client.php:365
./vendor/symfony/panther/src/Client.php:254
./tests/UserActionsTest.php:13

I searched on DuckDuckGo but nothing is related to Symfony, PHPUnit, or even PHP language.

I am leaning for a version problem, here is my composer.json:

{
// ...
    "require": {
        "php": ">=7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "composer/package-versions-deprecated": "1.11.99.1",
        "doctrine/annotations": "^1.11",
        "doctrine/doctrine-bundle": "^2.2",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.7",
        "sensio/framework-extra-bundle": "^5.6",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "4.4.*",
        "symfony/console": "4.4.*",
        "symfony/dotenv": "4.4.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "4.4.*",
        "symfony/framework-bundle": "4.4.*",
        "symfony/panther": "^0.8.0",
        "symfony/security-bundle": "4.4.*",
        "symfony/validator": "4.4.*",
        "symfony/yaml": "4.4.*"
    },
    "require-dev": {
        "phpstan/extension-installer": "^1.0",
        "phpstan/phpstan": "^0.12.58",
        "phpstan/phpstan-beberlei-assert": "^0.12.3",
        "symfony/browser-kit": "4.4.*",
        "symfony/css-selector": "4.4.*",
        "symfony/maker-bundle": "^1.24",
        "symfony/phpunit-bridge": "^5.2",
        "symfony/stopwatch": "^4.4",
        "symfony/twig-bundle": "^4.4",
        "symfony/web-profiler-bundle": "^4.4"
    },
// ...
}

And here is my phpunit.xml.dist:

<?xml version="1.0" encoding="UTF-8"?>
 
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="bin/.phpunit/phpunit.xsd"
         backupGlobals="false"
         colors="true"
         bootstrap="vendor/autoload.php"
>
    <php>
        <ini name="error_reporting" value="-1" />
        <env name="KERNEL_CLASS" value="App\Kernel" />
        <server name="APP_ENV" value="test" force="true" />
        <server name="SHELL_VERBOSITY" value="-1" />
        <server name="SYMFONY_PHPUNIT_REMOVE" value="" />
        <server name="SYMFONY_PHPUNIT_VERSION" value="7.5" />
        <env name="SYMFONY_DEPRECATIONS_HELPER" value="" />
 
        <!-- ###+ doctrine/doctrine-bundle ### -->
        <env name="DATABASE_URL" value="mysql://:@localhost:33060/" />
        <!-- ###- doctrine/doctrine-bundle ### -->
 
        <!-- ###+ symfony/swiftmailer-bundle ### -->
        <env name="MAILER_URL" value="null://localhost" />
        <!-- ###- symfony/swiftmailer-bundle ### -->
 
        <!-- ###+ symfony/framework-bundle ### -->
        <env name="APP_DEBUG" value="1" />
        <env name="APP_SECRET" value="" />
        <!-- ###- symfony/framework-bundle ### -->
    </php>
 
    <testsuites>
        <testsuite name="Project Test Suite">
            <directory>tests/</directory>
        </testsuite>
    </testsuites>
 
    <filter>
        <whitelist processUncoveredFilesFromWhitelist="true">
            <directory suffix=".php">src</directory>
        </whitelist>
    </filter>
 
    <listeners>
        <listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
    </listeners>
 
    <extensions>
        <!-- It begins a database transaction before every testcase and rolls it back after
            the test finished, so tests can manipulate the database without affecting other tests
        <extension class="\DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension" /> -->
        <extension class="Symfony\Component\Panther\ServerExtension" />
    </extensions>
</phpunit>

If I add the line as recommended by symfony/panther:

<listener class="Symfony\Component\Panther\ServerListener" />

This gives me the error:

1x: The "Symfony\Component\Panther\ServerListener" class is deprecated since Panther 0.6, use "Symfony\Component\Panther\ServerExtension" instead.

But using Symfony\Component\Panther\ServerExtension it gives me the error:

Class "Symfony\Component\Panther\ServerExtension" does not implement the PHPUnit\Framework\TestListener interface

Thank you in advance for your help.

1

There are 1 answers

0
Yannick Allegre On

Modification: the problem was fixed by uninstalling Chromium and installing it from the Snap Store (Linux Mint 20 / Ubuntu LTS 20.04.1):

sudo rm /etc/apt/preferences.d/nosnap.pref
sudo apt update
sudo apt full-upgrade
sudo apt install snapd
sudo snap install chromium