<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: v1.31</li>
<li>Operating System: Windows 11</li>
<li>Browser: Edge/WebView2</li>
<li>Other info: It is probably for all system and browsers, but checked only in this one</li>
</ul>
<h3 dir="auto">Source code</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I provided exact source code that allows reproducing the issue locally.</li>
</ul>




<p dir="auto"><strong>Test file (pseudocode)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="it('should check element is not leaking', async ({ page }) =&gt; {
  await Promise.all([
    () =&gt; page.locator('//*[@id=&quot;should_not_leak'div&quot;]').waitFor({ state: 'attached' }), 
    () =&gt; page.setContent(`&lt;div id='should_not_leak'div&gt;&lt;/div&gt;`) 
  ])
});"><pre class="notranslate"><span class="pl-en">it</span><span class="pl-kos">(</span><span class="pl-s">'should check element is not leaking'</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-k">await</span> <span class="pl-v">Promise</span><span class="pl-kos">.</span><span class="pl-en">all</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-s1">page</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'//*[@id="should_not_leak'</span><span class="pl-s1">div</span>"<span class="pl-kos">]</span>'<span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">waitFor</span><span class="pl-kos">(</span><span class="pl-kos">{</span> <span class="pl-c1">state</span>: <span class="pl-s">'attached'</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">=&gt;</span> <span class="pl-s1">page</span><span class="pl-kos">.</span><span class="pl-en">setContent</span><span class="pl-kos">(</span><span class="pl-s">`&lt;div id='should_not_leak'div&gt;&lt;/div&gt;`</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>Steps</strong></p>
<ul dir="auto">
<li>[Run the test]</li>
<li>[...]</li>
</ul>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">There is no detached div element at the end of the test</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">Playwright leaks element(s) found by locators, if there is <code class="notranslate">waitFor</code> called on them, due to internally used Handles and not disposing them.</p>
<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [1.31.1]</li>
<li>Operating System: [macOS 13.2]</li>
<li>Browser: [Google Chrome]</li>
</ul>
<h3 dir="auto">Screenshots of config file and terminal</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/12250556/221951699-069a2c91-2623-4e6e-af2a-9586ed550262.png"><img width="553" alt="Screenshot 2023-03-01 at 12 24 38 AM" src="https://user-images.githubusercontent.com/12250556/221951699-069a2c91-2623-4e6e-af2a-9586ed550262.png" style="max-width: 100%;"></a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/12250556/221951904-268e88af-d496-4c8b-a97e-59958bb298a2.png"><img width="412" alt="Screenshot 2023-03-01 at 12 25 28 AM" src="https://user-images.githubusercontent.com/12250556/221951904-268e88af-d496-4c8b-a97e-59958bb298a2.png" style="max-width: 100%;"></a></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/12250556/221953023-4d363b2e-770a-41c8-8080-783c2b8cec67.png"><img width="758" alt="Screenshot 2023-03-01 at 12 30 44 AM" src="https://user-images.githubusercontent.com/12250556/221953023-4d363b2e-770a-41c8-8080-783c2b8cec67.png" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected</strong></p>
<p dir="auto">Tests should run. I am using different roles, so authStates are being called and used in each file. (3rd screenshot)</p>
<p dir="auto"><strong>Actual</strong></p>
<p dir="auto">Tests not running, all getting skipped. Tests run when I comment the dependencies option in config file under project setup.</p>