<h3 dir="auto">System info</h3>
<ul dir="auto">
<li>Playwright Version: [v1.32.3]</li>
<li>Operating System: [Ubuntu 22.4, macOS Big Sur 11.7]</li>
<li>Browser: [Firefox]</li>
<li>Other info: with args <code class="notranslate">'--disable-blink-features=AutomationControlled',</code></li>
</ul>
<h3 dir="auto">Code Snippet</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const playwright = require(&quot;playwright&quot;)

const run = async (url) =&gt; {
    let browserContext = await playwright.firefox.launchPersistentContext(&quot;&quot;, {
        headless: false,
        javaScriptEnabled: true,
        ignoreHTTPSErrors: true,
        args:[
            '--disable-blink-features=AutomationControlled',
        ],
    });

    //get hang on the second launchPersistentContext call and finally crash
    let browserContext2 = await playwright.firefox.launchPersistentContext(&quot;&quot;, {
        headless: false,
        javaScriptEnabled: true,
        ignoreHTTPSErrors: true,
        args:[
            '--disable-blink-features=AutomationControlled',
        ],
    });

    const page = await browserContext.newPage()
    await page.goto(url)
}

let url ='https://www.sample.com'
run(url)"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">playwright</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">"playwright"</span><span class="pl-kos">)</span>

<span class="pl-k">const</span> <span class="pl-en">run</span> <span class="pl-c1">=</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-s1">url</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-s1">browserContext</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">playwright</span><span class="pl-kos">.</span><span class="pl-c1">firefox</span><span class="pl-kos">.</span><span class="pl-en">launchPersistentContext</span><span class="pl-kos">(</span><span class="pl-s">""</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-c1">javaScriptEnabled</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
        <span class="pl-c1">ignoreHTTPSErrors</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
        <span class="pl-c1">args</span>:<span class="pl-kos">[</span>
            <span class="pl-s">'--disable-blink-features=AutomationControlled'</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-c">//get hang on the second launchPersistentContext call and finally crash</span>
    <span class="pl-k">let</span> <span class="pl-s1">browserContext2</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">playwright</span><span class="pl-kos">.</span><span class="pl-c1">firefox</span><span class="pl-kos">.</span><span class="pl-en">launchPersistentContext</span><span class="pl-kos">(</span><span class="pl-s">""</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-c1">javaScriptEnabled</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
        <span class="pl-c1">ignoreHTTPSErrors</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
        <span class="pl-c1">args</span>:<span class="pl-kos">[</span>
            <span class="pl-s">'--disable-blink-features=AutomationControlled'</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-k">const</span> <span class="pl-s1">page</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">browserContext</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">page</span><span class="pl-kos">.</span><span class="pl-en">goto</span><span class="pl-kos">(</span><span class="pl-s1">url</span><span class="pl-kos">)</span>
<span class="pl-kos">}</span>

<span class="pl-k">let</span> <span class="pl-s1">url</span> <span class="pl-c1">=</span><span class="pl-s">'https://www.sample.com'</span>
<span class="pl-en">run</span><span class="pl-kos">(</span><span class="pl-s1">url</span><span class="pl-kos">)</span></pre></div>
<p dir="auto"><strong>Steps</strong></p>
<ul dir="auto">
<li>[Run above code]</li>
<li>[It will hang on the second <code class="notranslate">launchPersistentContext</code> call and finally crash with following info , sometimes even just one <code class="notranslate">launchPersistentContext</code> call, the issue still happens, it seems OK if not using <code class="notranslate">'--disable-blink-features=AutomationControlled',</code> ]</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

browserType.launchPersistentContext: Timeout 180000ms exceeded.
=========================== logs ===========================
&lt;launching&gt; xx/Library/Caches/ms-playwright/firefox-1391/firefox/Nightly.app/Contents/MacOS/firefox -no-remote -wait-for-browser -foreground -profile /var/folders/q4/pmzpltlj1kx7w9jp15r5mx28395l8m/T/playwright_firefoxdev_profile-YO14HW -juggler-pipe --disable-blink-features=AutomationControlled about:blank
&lt;launched&gt; pid=46488
[pid=46488][out] console.warn: services.settings: Ignoring preference override of remote settings server
[pid=46488][out] console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
[pid=46488][out] console.error: ({})
[pid=46488][out] 
[pid=46488][out] Juggler listening to the pipe
[pid=46488][out] console.error: &quot;Warning: unrecognized command line flag -wait-for-browser\n&quot;
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.warn: SearchSettings: &quot;get: No settings file exists, new profile?&quot; (new NotFoundError(&quot;Could not open the file at /var/folders/q4/pmzpltlj1kx7w9jp15r5mx28395l8m/T/playwright_firefoxdev_profile-YO14HW/search.json.mozlz4&quot;, (void 0)))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] WARNING: removeEventListener throws SecurityError: Permission denied to access property &quot;removeEventListener&quot; on cross-origin object at addEventListener/&lt;@chrome://juggler/content/Helper.js:49:61
[pid=46488][out] removeListeners@chrome://juggler/content/Helper.js:78:16
[pid=46488][out] _dispose@chrome://juggler/content/content/JugglerFrameChild.jsm:47:12
[pid=46488][out] didDestroy@chrome://juggler/content/content/JugglerFrameChild.jsm:59:10
[pid=46488][out] 
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError(&quot;The URI is malformed.&quot;, (void 0), 133))
============================================================
    at async run (.../xx.js:28:27) {
  name: 'TimeoutError'
} ```"><pre class="notranslate"><code class="notranslate">node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

browserType.launchPersistentContext: Timeout 180000ms exceeded.
=========================== logs ===========================
&lt;launching&gt; xx/Library/Caches/ms-playwright/firefox-1391/firefox/Nightly.app/Contents/MacOS/firefox -no-remote -wait-for-browser -foreground -profile /var/folders/q4/pmzpltlj1kx7w9jp15r5mx28395l8m/T/playwright_firefoxdev_profile-YO14HW -juggler-pipe --disable-blink-features=AutomationControlled about:blank
&lt;launched&gt; pid=46488
[pid=46488][out] console.warn: services.settings: Ignoring preference override of remote settings server
[pid=46488][out] console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
[pid=46488][out] console.error: ({})
[pid=46488][out] 
[pid=46488][out] Juggler listening to the pipe
[pid=46488][out] console.error: "Warning: unrecognized command line flag -wait-for-browser\n"
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /var/folders/q4/pmzpltlj1kx7w9jp15r5mx28395l8m/T/playwright_firefoxdev_profile-YO14HW/search.json.mozlz4", (void 0)))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] WARNING: removeEventListener throws SecurityError: Permission denied to access property "removeEventListener" on cross-origin object at addEventListener/&lt;@chrome://juggler/content/Helper.js:49:61
[pid=46488][out] removeListeners@chrome://juggler/content/Helper.js:78:16
[pid=46488][out] _dispose@chrome://juggler/content/content/JugglerFrameChild.jsm:47:12
[pid=46488][out] didDestroy@chrome://juggler/content/content/JugglerFrameChild.jsm:59:10
[pid=46488][out] 
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
[pid=46488][out] console.error: (new SyntaxError("The URI is malformed.", (void 0), 133))
============================================================
    at async run (.../xx.js:28:27) {
  name: 'TimeoutError'
} ```
</code></pre></div>
<p dir="auto"><strong>Context:</strong></p>
<ul dir="auto">
<li>Playwright Version: 1.25.2</li>
<li>Operating System: Linux</li>
<li>Node.js version: 16.17.0</li>
<li>Browser: Chromium</li>
<li>Extra: [any specific details about your environment]</li>
</ul>


<p dir="auto"><strong>Code Snippet</strong></p>
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;div data-test=&quot;work-package&quot;&gt;
  &lt;div data-test=&quot;input-work-package-name&quot;&gt;
    &lt;input type=&quot;text&quot; /&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;div data-test=&quot;work-package&quot;&gt;
  &lt;div data-test=&quot;input-work-package-name&quot;&gt;
    &lt;input type=&quot;text&quot; /&gt;
  &lt;/div&gt;
&lt;/div&gt;"><pre class="notranslate"><span class="pl-kos">&lt;</span><span class="pl-ent">div</span> <span class="pl-c1">data-test</span>="<span class="pl-s">work-package</span>"<span class="pl-kos">&gt;</span>
  <span class="pl-kos">&lt;</span><span class="pl-ent">div</span> <span class="pl-c1">data-test</span>="<span class="pl-s">input-work-package-name</span>"<span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">input</span> <span class="pl-c1">type</span>="<span class="pl-s">text</span>" /&gt;
  <span class="pl-kos">&lt;/</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;</span><span class="pl-ent">div</span> <span class="pl-c1">data-test</span>="<span class="pl-s">work-package</span>"<span class="pl-kos">&gt;</span>
  <span class="pl-kos">&lt;</span><span class="pl-ent">div</span> <span class="pl-c1">data-test</span>="<span class="pl-s">input-work-package-name</span>"<span class="pl-kos">&gt;</span>
    <span class="pl-kos">&lt;</span><span class="pl-ent">input</span> <span class="pl-c1">type</span>="<span class="pl-s">text</span>" /&gt;
  <span class="pl-kos">&lt;/</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span>
<span class="pl-kos">&lt;/</span><span class="pl-ent">div</span><span class="pl-kos">&gt;</span></pre></div>
<p dir="auto"><strong>Describe the bug</strong></p>
<p dir="auto">I am trying to assign a locator of some div (somehow like some rows) and from that the first element to a variable. To then use DRY code to access elements in that specific row. But those are not detected somehow:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// not working code
const workPackageLocator = page.locator('[data-test=work-package]').nth(1);
const d = await workPackageLocator.locator('[data-test=input-work-package-name] input[type=text]').count(); // d = 0"><pre class="notranslate"><span class="pl-c">// not working code</span>
<span class="pl-k">const</span> <span class="pl-s1">workPackageLocator</span> <span class="pl-c1">=</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">'[data-test=work-package]'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">nth</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">d</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">workPackageLocator</span><span class="pl-kos">.</span><span class="pl-en">locator</span><span class="pl-kos">(</span><span class="pl-s">'[data-test=input-work-package-name] input[type=text]'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">count</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// d = 0</span></pre></div>
<p dir="auto">When I do the same thing, but with only a single locator and without <code class="notranslate">nth(1)</code> its working as expected, but this would create quite some duplicate code.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="// work around
const d = page.locator('[data-test=work-package] [data-test=input-work-package-name] input[type=text]').count(); // d = 1"><pre class="notranslate"><span class="pl-c">// work around</span>
<span class="pl-k">const</span> <span class="pl-s1">d</span> <span class="pl-c1">=</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">'[data-test=work-package] [data-test=input-work-package-name] input[type=text]'</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">count</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-c">// d = 1</span></pre></div>
<p dir="auto">Only other idea would be to use a string concatenation like:</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const workPackageLocator = '[data-test=work-package]';
const d = page.locator(`${workPackageLocator} [data-test=input-work-package-name] input[type=text]').count();"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">workPackageLocator</span> <span class="pl-c1">=</span> <span class="pl-s">'[data-test=work-package]'</span><span class="pl-kos">;</span>
<span class="pl-k">const</span> <span class="pl-s1">d</span> <span class="pl-c1">=</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">`<span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">workPackageLocator</span><span class="pl-kos">}</span></span></span> <span class="pl-kos">[</span><span class="pl-s1">data</span><span class="pl-c1">-</span><span class="pl-s1">test</span><span class="pl-c1">=</span><span class="pl-s1">input</span><span class="pl-c1">-</span><span class="pl-s1">work</span><span class="pl-c1">-</span><span class="pl-s1">package</span><span class="pl-c1">-</span><span class="pl-s1">name</span><span class="pl-kos">]</span> <span class="pl-s1">input</span><span class="pl-kos">[</span><span class="pl-s1">type</span><span class="pl-c1">=</span><span class="pl-s1">text</span><span class="pl-kos">]</span>'<span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">count</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>