Issue 1:
System info

Playwright Version: [v1.32.3]

Operating System: [Ubuntu 22.4, macOS Big Sur 11.7]

Browser: [Firefox]

Other info: with args '--disable-blink-features=AutomationControlled',

Code Snippet

const playwright = require("playwright")

const run = async (url) => {
let browserContext = await playwright.firefox.launchPersistentContext("", {
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("", {
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)

Steps

[Run above code]

[It will hang on the second launchPersistentContext call and finally crash with following info , sometimes even just one launchPersistentContext call, the issue still happens, it seems OK if not using '--disable-blink-features=AutomationControlled', ]

node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^

browserType.launchPersistentContext: Timeout 180000ms exceeded.
=========================== logs ===========================
<launching> 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
<launched> 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/<@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'
} ```

Issue 2:
Context:

Playwright Version: 1.25.2

Operating System: Linux

Node.js version: 16.17.0

Browser: Chromium

Extra: [any specific details about your environment]

Code Snippet

<div data-test="work-package">
<div data-test="input-work-package-name">
<input type="text" />
</div>
</div>
<div data-test="work-package">
<div data-test="input-work-package-name">
<input type="text" />
</div>
</div>

Describe the bug

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:

// 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

When I do the same thing, but with only a single locator and without nth(1) its working as expected, but this would create quite some duplicate code.

// work around
const d = page.locator('[data-test=work-package] [data-test=input-work-package-name] input[type=text]').count(); // d = 1

Only other idea would be to use a string concatenation like:

const workPackageLocator = '[data-test=work-package]';
const d = page.locator(`${workPackageLocator} [data-test=input-work-package-name] input[type=text]').count();