title: Symfony Panther : cannot run multiple tests at once
body: <p>I am currently writing tests for my Symfony project, I haven't encountered any problems with regular testing like WebTestCase.
  But now that I am using Panther for some of them, I encounter errors when I try to launch multiple panther tests at once. The first one always works properly but the next ones get weird errors depending on how I try to arrange them and I can't manage to find an exit out of this.</p>
  <p>Here's my code, I've regrouped all of my panther tests in a same class.</p>
  <pre><code>namespace App\Tests;
  
  use App\Entity\User;
  use App\Repository\TrainingRepository;
  use App\Repository\QuestionRepository;
  use Symfony\Component\Panther\PantherTestCase;
  
  class PantherTest extends PantherTestCase
  {
      public function testCreateTrainingOneUser(): void
      {
          $client = static::createPantherClient();
  
          $crawler = $client-&gt;request('GET', '/');
          $client-&gt;submitForm('Sign in', [
              'email'     =&gt; 'test@test.com',
              'password'  =&gt; 'toto']);
          $crawler = $client-&gt;request('GET', '/dashboard/training/create_training');
          $this-&gt;assertSelectorTextContains('.h3', 'Créer une formation');
  
          $client-&gt;executeScript(&quot;document.querySelector('#add_user_button').click()&quot;);
          $client-&gt;waitFor('#create_training_users_0_email');
  
          $client-&gt;submitForm('Create', [
              &quot;create_training[title]&quot; =&gt; 'test',
              &quot;create_training[description]&quot; =&gt; 'un test',
              &quot;create_training[image_url]&quot; =&gt; 'image_url',
              &quot;create_training[users][0][email]&quot; =&gt; 1,
              &quot;create_training[checklist][]&quot; =&gt; 'option1',
          ]);
          $trainingRepository = static::$container-&gt;get(TrainingRepository::class);
  
          $testTraining = $trainingRepository-&gt;findOneBy(['title' =&gt; 'test']);
          $this-&gt;assertNotEmpty($testTraining);
      }
  
      public function testCreateQuestion(): void
      {
          $client = static::createPantherClient();
  
          $crawler = $client-&gt;request('GET', '/');
          $client-&gt;submitForm('Sign in', [
              'email'     =&gt; 'test@test.com',
              'password'  =&gt; 'toto']);
          $crawler = $client-&gt;request('GET', '/dashboard/training/1/qcm/1/create_question');
          $this-&gt;assertSelectorTextContains('.h3', 'Créer une nouvelle question');
  
          $client-&gt;executeScript(&quot;document.querySelector('.answer-add').click()&quot;);
          $client-&gt;waitFor('#create_question_answers_0_label');
  
          $client-&gt;submitForm('Créer', [
              &quot;create_question[label]&quot; =&gt; 'test',
              &quot;create_question[hint]&quot; =&gt; 'un test',
              &quot;create_question[type]&quot; =&gt; 1,
              &quot;create_question[solution]&quot; =&gt; 'le test',
              &quot;create_question[associated_chapters]&quot; =&gt; 'test1',
              &quot;create_question[state]&quot; =&gt; 'en cours',
              &quot;create_question[answers][0][label]&quot; =&gt; 'réponse test',
              &quot;create_question[answers][0][is_right]&quot; =&gt; true,
              &quot;create_question[answers][0][position]&quot; =&gt; 1,
          ]);
  
          $questionRepository = static::$container-&gt;get(QuestionRepository::class);
          $testQuestion = $questionRepository-&gt;findOneBy(['label' =&gt; 'test', 'qcm' =&gt; 1]);
          $this-&gt;assertNotEmpty($testQuestion);
      }
  }
  </code></pre>
  <p>Both of thoses tests are perfectly functionnal when launched while commenting the other, but if both of them are 'active' only the first one succeeds and I get this error with this current code setup.</p>
  <pre><code>✘ Create question
     ┐
     ├ InvalidArgumentException: The current node list is empty.
     │
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/symfony/panther/src/DomCrawler/Crawler.php:396
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/symfony/panther/src/DomCrawler/Crawler.php:308
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/symfony/browser-kit/AbstractBrowser.php:323
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/tests/PantherTest.php:45
  </code></pre>
  <p>Line 45 is this one there</p>
  <pre><code>44- $client-&gt;submitForm('Sign in', [
  45-            'email'     =&gt; 'test@test.com',
  46-            'password'  =&gt; 'toto']);
  </code></pre>
  <p>Since our web site use authentification, I currentmy have to login using the submit form method since loginUser available with WebTestCase doesn't work with Panther.</p>
  <p><strong>Update 1 :</strong>
  As suggested by the 1st comment, the &quot;session&quot; might already logged in.
  Which his indeed the case after a small test</p>
  <pre><code>public function testCreateQuestion(): void
      {
          $client = static::createPantherClient();
  
          $crawler = $client-&gt;request('GET', '/dashboard/training/1/qcm/1/create_question');
          $this-&gt;assertSelectorTextContains('.h3', 'Créer une nouvelle question');
  
          /*$client-&gt;executeScript(&quot;document.querySelector('.answer-add').click()&quot;);
          $client-&gt;waitFor('#create_question_answers_0_label');
  
          $client-&gt;submitForm('Créer', [
              &quot;create_question[label]&quot; =&gt; 'test',
              &quot;create_question[hint]&quot; =&gt; 'un test',
              &quot;create_question[type]&quot; =&gt; 1,
              &quot;create_question[solution]&quot; =&gt; 'le test',
              &quot;create_question[associated_chapters]&quot; =&gt; 'test1',
              &quot;create_question[state]&quot; =&gt; 'en cours',
              &quot;create_question[answers][0][label]&quot; =&gt; 'réponse test',
              &quot;create_question[answers][0][is_right]&quot; =&gt; true,
              &quot;create_question[answers][0][position]&quot; =&gt; 1,
          ]);
  
          $questionRepository = static::$container-&gt;get(QuestionRepository::class);
          $testQuestion = $questionRepository-&gt;findOneBy(['label' =&gt; 'test', 'qcm' =&gt; 1]);
          $this-&gt;assertNotEmpty($testQuestion);*/
      }
  </code></pre>
  <p>This is my new 2nd test, and this assertion works, indicating that I am still considered as logged in and can navigate freely.
  But now if I uncomment the end of the test, it take a very long time to complete (around 1min with the commented code and around 2mins without)</p>
  <p>And without the comment I get the following error</p>
  <pre><code>✘ Create question
     ┐
     ├ Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session/fb755275a1734b52965592ca0765e4c4/element/7539b385-285d-4d86-ac88-502835620960/click
     ├                                                                                                                                                                                     
     ├ Operation timed out after 30001 milliseconds with 0 bytes received                                                                                                                  
     │
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:332
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:591
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/php-webdriver/webdriver/lib/Remote/RemoteExecuteMethod.php:27
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebElement.php:76
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/symfony/panther/src/Client.php:244
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/vendor/symfony/browser-kit/AbstractBrowser.php:325
     ╵ /home/simon/Tek3/Stage/PhysioAc_Login/tests/PantherTest.php:50
  </code></pre>
  <p>The line 50 is the one just after the sumbitForm() method.</p>