<p dir="auto">When trying to use evaluateAll or dispatchEvent in a specific web page, an TypeError: extraEngines is not iterable error is throw</p>
<p dir="auto">Seems to be the same bug as <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1440014352" data-permission-text="Title is private" data-url="https://github.com/microsoft/playwright/issues/18641" data-hovercard-type="issue" data-hovercard-url="/microsoft/playwright/issues/18641/hovercard" href="https://github.com/microsoft/playwright/issues/18641">#18641</a> that was closed due to lack of public reproduction. This can be reproduced in public (see below)</p>
<p dir="auto">Its similar to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1718486575" data-permission-text="Title is private" data-url="https://github.com/microsoft/playwright/issues/23192" data-hovercard-type="issue" data-hovercard-url="/microsoft/playwright/issues/23192/hovercard" href="https://github.com/microsoft/playwright/issues/23192">#23192</a> in the same web page / app but unlike the other bug this occurs using the library also, not only the codegen</p>




<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.33]</li>
<li>Operating System: [Windows 10]</li>
<li>Browser: [Chromium]</li>
<li>Other info:</li>
</ul>
<h3 dir="auto">Source code</h3>
<p dir="auto">-[x] I provided exact source code that allows reproducing the issue locally.</p>

<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { chromium, Page } from 'playwright'

async function testSAWTypeError() {
  const browser = await chromium.launch({ headless: false })
  const context = await browser.newContext()
  const result = await context.newPage()
  await result.goto('https://saw.trixti.com.br/saw')
  const s = await result.locator('a').evaluateAll((els) =&gt; {
    return els.map((el) =&gt; el.textContent)
  })
  console.log(s)
  await result.locator('input#submitForm').dispatchEvent('click')
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">chromium</span><span class="pl-kos">,</span> <span class="pl-v">Page</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'playwright'</span>

<span class="pl-k">async</span> <span class="pl-k">function</span> <span class="pl-en">testSAWTypeError</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">const</span> <span class="pl-s1">browser</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">chromium</span><span class="pl-kos">.</span><span class="pl-en">launch</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">headless</span>: <span class="pl-c1">false</span> <span class="pl-kos">}</span><span class="pl-kos">)</span>
  <span class="pl-k">const</span> <span class="pl-s1">context</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">browser</span><span class="pl-kos">.</span><span class="pl-en">newContext</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
  <span class="pl-k">const</span> <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">context</span><span class="pl-kos">.</span><span class="pl-en">newPage</span><span class="pl-kos">(</span><span class="pl-kos">)</span>
  <span class="pl-k">await</span> <span class="pl-s1">result</span><span class="pl-kos">.</span><span class="pl-en">goto</span><span class="pl-kos">(</span><span class="pl-s">'https://saw.trixti.com.br/saw'</span><span class="pl-kos">)</span>
  <span class="pl-k">const</span> <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">result</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'a'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">evaluateAll</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">els</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">return</span> <span class="pl-s1">els</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span><span class="pl-kos">(</span><span class="pl-s1">el</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-s1">el</span><span class="pl-kos">.</span><span class="pl-c1">textContent</span><span class="pl-kos">)</span>
  <span class="pl-kos">}</span><span class="pl-kos">)</span>
  <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s1">s</span><span class="pl-kos">)</span>
  <span class="pl-k">await</span> <span class="pl-s1">result</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'input#submitForm'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">dispatchEvent</span><span class="pl-kos">(</span><span class="pl-s">'click'</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span></pre></div>



<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>Enter <a href="https://saw.trixti.com.br/saw" rel="nofollow">https://saw.trixti.com.br/saw</a></li>
<li>Try to call <code class="notranslate">locator.dispatchEvent</code> or <code class="notranslate">locator.evaluateAll</code></li>
</ul>
<p dir="auto"><strong>Expected</strong><br>
Should not crash</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">It crashes</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: v1.32</li>
<li>Operating System: Windows 10, Ubuntu 20</li>
<li>Browser: Chromium</li>
<li>Other info:</li>
</ul>
<p dir="auto">When using a "setup" in project dependencies and you run a test with <code class="notranslate">--repeat-each</code> the setup step is repeated as well.<br>
I don't know if this is bug or "works as design" but it would be nice if the setup code only ran once. We can work around this my just running the setup one and then run the test with a project that do not have the setup as dependency, like this (see the  playwright.config.ts below):</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="npx playwright test ./tests/setup.ts &amp;&amp; npx playwright test ./tests/myTest.spec.ts --project local-chromium --repeat-each 25 --workers 1"><pre class="notranslate"><span class="pl-s1">npx</span> <span class="pl-s1">playwright</span> <span class="pl-s1">test</span> <span class="pl-kos">.</span><span class="pl-c1">/</span><span class="pl-s1">tests</span><span class="pl-c1">/</span><span class="pl-s1">setup</span><span class="pl-kos">.</span><span class="pl-c1">ts</span> <span class="pl-c1">&amp;&amp;</span> <span class="pl-s1">npx</span> <span class="pl-s1">playwright</span> <span class="pl-s1">test</span> <span class="pl-kos">.</span><span class="pl-c1">/</span><span class="pl-s1">tests</span><span class="pl-c1">/</span><span class="pl-s1">myTest</span><span class="pl-kos">.</span><span class="pl-c1">spec</span><span class="pl-kos">.</span><span class="pl-c1">ts</span> <span class="pl-c1">--</span><span class="pl-s1">project</span> <span class="pl-s1">local</span><span class="pl-c1">-</span><span class="pl-s1">chromium</span> <span class="pl-c1">--</span><span class="pl-s1">repeat</span><span class="pl-c1">-</span><span class="pl-s1">each</span> <span class="pl-c1">25</span> <span class="pl-c1">--</span><span class="pl-s1">workers</span> <span class="pl-c1">1</span></pre></div>
<p dir="auto">But this is not optimal since the second playwright run will overwrite the report from the setup.</p>
<h3 dir="auto">Source code</h3>
<ul dir="auto">
<li>[*] I provided exact source code that allows reproducing the issue locally.</li>
</ul>




<p dir="auto"><strong>Config file</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
   {
      name: 'setup',
      testMatch: /setup\.ts/,
    },
    {
      name: 'chromium',
      use: {
        ...devices['Desktop Chrome'],
      },
      dependencies: ['setup'],
    },
    {
      name: 'local-chromium',
      use: {
        ...devices['Desktop Chrome'],
      },
    },
});"><pre class="notranslate"><span class="pl-c">// playwright.config.ts</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">defineConfig</span><span class="pl-kos">,</span> <span class="pl-s1">devices</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@playwright/test'</span><span class="pl-kos">;</span>

<span class="pl-k">export</span> <span class="pl-k">default</span> <span class="pl-en">defineConfig</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
  <span class="pl-c1">projects</span>: <span class="pl-kos">[</span>
   <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">'setup'</span><span class="pl-kos">,</span>
      <span class="pl-c1">testMatch</span>: <span class="pl-pds"><span class="pl-c1">/</span>setup<span class="pl-cce">\.</span>ts<span class="pl-c1">/</span></span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">'chromium'</span><span class="pl-kos">,</span>
      <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
        ...<span class="pl-s1">devices</span><span class="pl-kos">[</span><span class="pl-s">'Desktop Chrome'</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
      <span class="pl-c1">dependencies</span>: <span class="pl-kos">[</span><span class="pl-s">'setup'</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">{</span>
      <span class="pl-c1">name</span>: <span class="pl-s">'local-chromium'</span><span class="pl-kos">,</span>
      <span class="pl-c1">use</span>: <span class="pl-kos">{</span>
        ...<span class="pl-s1">devices</span><span class="pl-kos">[</span><span class="pl-s">'Desktop Chrome'</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
      <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span><span class="pl-kos"></span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Test file (self-contained)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// setup.ts
import { test as setup } from '@playwright/test';
setup('setup', async ({}) =&gt; {
  // setup code that takes long time
});"><pre class="notranslate"><span class="pl-c">// setup.ts</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">test</span> <span class="pl-k">as</span> <span class="pl-s1">setup</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">'@playwright/test'</span><span class="pl-kos">;</span>
<span class="pl-en">setup</span><span class="pl-kos">(</span><span class="pl-s">'setup'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span><span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-c">// setup code that takes long time</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// myTest.spec.ts
test('some fine test', async ({ page }) =&gt; {
  // some excellent test code
});"><pre class="notranslate"><span class="pl-c">// myTest.spec.ts</span>
<span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">'some fine test'</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">{</span> page <span class="pl-kos">}</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
  <span class="pl-c">// some excellent test code</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>Run the test: npx playwright test ./tests/myTest.spec.ts --repeat-each 3 --workers 1</li>
</ul>
<p dir="auto"><strong>Expected</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  ✓  1 [setup] › setup.ts:11:6 › setup (11.0s)
  ✓  2 [chromium] › myTest.spec.ts › some fine test (740ms)
  ✓  3 [chromium] › myTest.spec.ts › some fine test (647ms)
  ✓  4 [chromium] › myTest.spec.ts› some fine test (656ms)"><pre class="notranslate"><code class="notranslate">  ✓  1 [setup] › setup.ts:11:6 › setup (11.0s)
  ✓  2 [chromium] › myTest.spec.ts › some fine test (740ms)
  ✓  3 [chromium] › myTest.spec.ts › some fine test (647ms)
  ✓  4 [chromium] › myTest.spec.ts› some fine test (656ms)
</code></pre></div>
<p dir="auto">the setup code should only run once</p>
<p dir="auto"><strong>Actual</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  ✓  1 [setup] › setup.ts:11:6 › setup (12.7s)
  ✓  2 [setup] › setup.ts:11:6 › setup (10.1s)
  ✓  3 [setup] › setup.ts:11:6 › setup (11.0s)
  ✓  4 [chromium] › myTest.spec.ts › some fine test (740ms)
  ✓  5 [chromium] › myTest.spec.ts › some fine test (647ms)
  ✓  6 [chromium] › myTest.spec.ts› some fine test (656ms)"><pre class="notranslate"><code class="notranslate">  ✓  1 [setup] › setup.ts:11:6 › setup (12.7s)
  ✓  2 [setup] › setup.ts:11:6 › setup (10.1s)
  ✓  3 [setup] › setup.ts:11:6 › setup (11.0s)
  ✓  4 [chromium] › myTest.spec.ts › some fine test (740ms)
  ✓  5 [chromium] › myTest.spec.ts › some fine test (647ms)
  ✓  6 [chromium] › myTest.spec.ts› some fine test (656ms)
</code></pre></div>
<p dir="auto">The set up is ran the "repeat-each" number of times</p>