From 33cc01f1c44d59905150b597c7188a17e336b0df Mon Sep 17 00:00:00 2001
From: Copilot <223556219+Copilot@users.noreply.github.com>
Date: Wed, 5 Aug 2026 07:31:13 +0000
Subject: [PATCH 1/3] test(firefox): fixme flaky codegen pierceFrames
disambiguation on Intel macOS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Hi, I'm the Playwright bot. `cli codegen with pierceFrames › should prepend the frame selector to disambiguate` is flaky, but **only on `firefox-macos-15-large` (Intel macOS)** — 8 failures / 46 runs (17.4%) in the recent window, and zero failures on every other bot (chromium, webkit, firefox arm64, ubuntu). Reproduced locally on Intel macOS with `--repeat-each=15 --workers=6`: 3 flaky, all the same failure.
Root cause is a timing race, not a bad assertion: `buildFullSelectorForFrame` races the cross-frame piercing-selector resolution against a hardcoded 2000ms deadline and, on timeout, falls back to the `internal:control=no-pierce-frames` opt-out. Under load on the Intel macOS runner that race times out, so the recorder emits `page.pierceFrames({ pierce: false }).locator('#frame1')…` instead of the expected piercing selector. `test.slow()` wouldn't help — the 2s budget is internal to the recorder, independent of the test timeout. Same Intel-macOS-firefox-under-load class as #41811.
Scoped `test.fixme` to `browserName === 'firefox' && isMac && process.arch === 'x64'`; the test still runs everywhere else.
Run history for `firefox-macos-15-large` (oldest first, 46 runs):
[🟧](https://github.com/microsoft/playwright/actions/runs/30490403874/attempts/1)[🟥](https://github.com/microsoft/playwright/actions/runs/30493031010/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30495285330/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30530696555/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30534756293/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30539645601/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30542293233/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30542345092/attempts/1)[🟧](https://github.com/microsoft/playwright/actions/runs/30559579795/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30565052100/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30568188818/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30568293053/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30568320872/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30577572373/attempts/1)[🟥](https://github.com/microsoft/playwright/actions/runs/30581383958/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30581357288/attempts/1)[🟧](https://github.com/microsoft/playwright/actions/runs/30581405526/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30585190825/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30618799783/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30624512498/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30653773411/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30667286182/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30667347031/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30833251658/attempts/1)[🟥](https://github.com/microsoft/playwright/actions/runs/30850656923/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30850749658/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30854798001/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30859315578/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30859305376/attempts/1)[🟥](https://github.com/microsoft/playwright/actions/runs/30859360344/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30885108613/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30885140825/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30885208556/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30885237385/attempts/1)[🟥](https://github.com/microsoft/playwright/actions/runs/30885274230/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30917613834/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30927071352/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30927719515/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30930057055/attempts/1)[🟥](https://github.com/microsoft/playwright/actions/runs/30933859878/attempts/1)[🟥](https://github.com/microsoft/playwright/actions/runs/30934926278/attempts/1)[🟥](https://github.com/microsoft/playwright/actions/runs/30940141663/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30945227770/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30954253724/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30954381228/attempts/1)[🟩](https://github.com/microsoft/playwright/actions/runs/30955628029/attempts/1)
What I verified locally (Intel macOS, x64)
- Reproduced: `npm run ftest -- tests/library/inspector/cli-codegen-3.spec.ts:1169 --repeat-each=15 --workers=6` -> 3 flaky with the `pierce: false` opt-out.
- After fix: firefox -> `1 skipped`; chromium (`npm run ctest -- …:1169`) -> `1 passed`.
- `npm run flint` -> clean.
- CI run: https://github.com/microsoft/playwright/actions/runs/30984018624
Suggested-reviewer: dgozman
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
tests/library/inspector/cli-codegen-3.spec.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/library/inspector/cli-codegen-3.spec.ts b/tests/library/inspector/cli-codegen-3.spec.ts
index 5d3852b89ce1b..5cbc55173a491 100644
--- a/tests/library/inspector/cli-codegen-3.spec.ts
+++ b/tests/library/inspector/cli-codegen-3.spec.ts
@@ -1166,7 +1166,8 @@ test.describe('cli codegen with pierceFrames', () => {
await page.getByText('Hello2').click();`);
});
- test('should prepend the frame selector to disambiguate', async ({ openRecorder, server }) => {
+ test('should prepend the frame selector to disambiguate', async ({ openRecorder, server, browserName, isMac }) => {
+ test.fixme(browserName === 'firefox' && isMac && process.arch === 'x64', 'Cross-frame selector disambiguation races the recorder\'s 2s deadline under load on Intel macOS, emitting the pierce:false opt-out. https://github.com/microsoft/playwright/issues/41811');
const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
From 9fa9ed45a1ef306ad6fa9debe8edb949824c5c0d Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 5 Aug 2026 09:54:02 +0000
Subject: [PATCH 2/3] test(firefox): extend codegen frame selector timeout on
Intel macOS
Co-authored-by: Skn0tt <14912729+Skn0tt@users.noreply.github.com>
---
packages/playwright-core/src/server/recorder.ts | 10 +++++-----
.../src/server/recorder/recorderUtils.ts | 14 +++++++-------
tests/library/inspector/cli-codegen-3.spec.ts | 5 +++--
tests/library/inspector/inspectorTest.ts | 2 +-
4 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/packages/playwright-core/src/server/recorder.ts b/packages/playwright-core/src/server/recorder.ts
index e1461dbab79d3..e8e5b246c7186 100644
--- a/packages/playwright-core/src/server/recorder.ts
+++ b/packages/playwright-core/src/server/recorder.ts
@@ -46,7 +46,7 @@ import type { RegisteredListener } from '@utils/eventsHelper';
const recorderSymbol = Symbol('recorderSymbol');
type BindingSource = { frame: Frame, page: Page };
-type RecorderParams = channels.BrowserContextEnableRecorderParams & { hideToolbar?: boolean };
+type RecorderParams = channels.BrowserContextEnableRecorderParams & { hideToolbar?: boolean, __testHookFrameSelectorTimeout?: number };
export const RecorderEvent = {
PausedStateChanged: 'pausedStateChanged',
@@ -194,7 +194,7 @@ export class Recorder extends EventEmitter implements Instrume
});
await this._context.exposeBinding(progress, '__pw_recorderElementPicked', async ({ frame }, elementInfo: ElementInfo) => {
- const selector = await buildFullSelectorForFrame(progress, frame, elementInfo.selector);
+ const selector = await buildFullSelectorForFrame(progress, frame, elementInfo.selector, this._params.__testHookFrameSelectorTimeout);
this.emit(RecorderEvent.ElementPicked, { selector, ariaSnapshot: elementInfo.ariaSnapshot }, true);
});
@@ -540,15 +540,15 @@ export class Recorder extends EventEmitter implements Instrume
}
private async _performAction(progress: Progress, frame: Frame, action: actions.PerformableAction) {
- const selector = await buildFullSelectorForFrame(progress, frame, action.selector);
+ const selector = await buildFullSelectorForFrame(progress, frame, action.selector, this._params.__testHookFrameSelectorTimeout);
await performAction(progress, frame._page.mainFrame(), { ...action, selector });
}
private async _recordAction(progress: Progress, frame: Frame, action: actions.Action, preconditionSelector?: string) {
if (preconditionSelector)
- this._signalProcessor.signal(frame, { name: 'expect', selector: await buildFullSelectorForFrame(progress, frame, preconditionSelector) });
+ this._signalProcessor.signal(frame, { name: 'expect', selector: await buildFullSelectorForFrame(progress, frame, preconditionSelector, this._params.__testHookFrameSelectorTimeout) });
if ('selector' in action)
- action.selector = await buildFullSelectorForFrame(progress, frame, action.selector);
+ action.selector = await buildFullSelectorForFrame(progress, frame, action.selector, this._params.__testHookFrameSelectorTimeout);
const actionInContext: actions.ActionInContext = {
pageGuid: frame._page.guid,
action,
diff --git a/packages/playwright-core/src/server/recorder/recorderUtils.ts b/packages/playwright-core/src/server/recorder/recorderUtils.ts
index eb18550169e0e..5d1523a5def09 100644
--- a/packages/playwright-core/src/server/recorder/recorderUtils.ts
+++ b/packages/playwright-core/src/server/recorder/recorderUtils.ts
@@ -28,8 +28,8 @@ function buildFullSelector(framePath: string[], selector: string) {
return [...framePath, selector].join(' >> internal:control=enter-frame >> ');
}
-export async function buildFullSelectorForFrame(progress: Progress, frame: Frame, selector: string): Promise {
- const framePath = await generateFrameSelector(progress, frame);
+export async function buildFullSelectorForFrame(progress: Progress, frame: Frame, selector: string, timeout = 2000): Promise {
+ const framePath = await generateFrameSelector(progress, frame, timeout);
if (!frame._page.browserContext._options.pierceFrames || !framePath.length)
return buildFullSelector(framePath, selector);
@@ -40,7 +40,7 @@ export async function buildFullSelectorForFrame(progress: Progress, frame: Frame
if (await resolvesToFrame(progress, candidate, frame))
return candidate;
}
- }, monotonicTime() + 2000));
+ }, monotonicTime() + timeout));
if (!result.timedOut && result.result)
return result.result;
@@ -83,14 +83,14 @@ export function metadataToCallLog(metadata: CallMetadata, status: CallLogStatus)
}
-async function generateFrameSelector(progress: Progress, frame: Frame): Promise {
+async function generateFrameSelector(progress: Progress, frame: Frame, timeout: number): Promise {
const selectorPromises: Promise[] = [];
progress.setAllowConcurrentOrNestedRaces(true);
while (frame) {
const parent = frame.parentFrame();
if (!parent)
break;
- selectorPromises.push(generateFrameSelectorInParent(progress, parent, frame));
+ selectorPromises.push(generateFrameSelectorInParent(progress, parent, frame, timeout));
frame = parent;
}
const result = await Promise.all(selectorPromises);
@@ -98,7 +98,7 @@ async function generateFrameSelector(progress: Progress, frame: Frame): Promise<
return result.reverse();
}
-async function generateFrameSelectorInParent(prgoress: Progress, parent: Frame, frame: Frame): Promise {
+async function generateFrameSelectorInParent(prgoress: Progress, parent: Frame, frame: Frame, timeout: number): Promise {
const result = await raceAgainstDeadline(async () => {
try {
const frameElement = await frame.frameElement(prgoress);
@@ -112,7 +112,7 @@ async function generateFrameSelectorInParent(prgoress: Progress, parent: Frame,
return selector;
} catch (e) {
}
- }, monotonicTime() + 2000);
+ }, monotonicTime() + timeout);
if (!result.timedOut && result.result)
return result.result;
diff --git a/tests/library/inspector/cli-codegen-3.spec.ts b/tests/library/inspector/cli-codegen-3.spec.ts
index 5cbc55173a491..2a170b055c828 100644
--- a/tests/library/inspector/cli-codegen-3.spec.ts
+++ b/tests/library/inspector/cli-codegen-3.spec.ts
@@ -1167,8 +1167,9 @@ test.describe('cli codegen with pierceFrames', () => {
});
test('should prepend the frame selector to disambiguate', async ({ openRecorder, server, browserName, isMac }) => {
- test.fixme(browserName === 'firefox' && isMac && process.arch === 'x64', 'Cross-frame selector disambiguation races the recorder\'s 2s deadline under load on Intel macOS, emitting the pierce:false opt-out. https://github.com/microsoft/playwright/issues/41811');
- const { page, recorder } = await openRecorder();
+ const { page, recorder } = await openRecorder({
+ __testHookFrameSelectorTimeout: browserName === 'firefox' && isMac && process.arch === 'x64' ? 10_000 : undefined,
+ });
await recorder.setContentAndWait(`
diff --git a/tests/library/inspector/inspectorTest.ts b/tests/library/inspector/inspectorTest.ts
index 9fa145a651b01..d6e8c9b87a832 100644
--- a/tests/library/inspector/inspectorTest.ts
+++ b/tests/library/inspector/inspectorTest.ts
@@ -27,7 +27,7 @@ export { expect } from '@playwright/test';
type CLITestArgs = {
recorderPageGetter: () => Promise;
closeRecorder: () => Promise;
- openRecorder: (options?: { testIdAttributeName?: string, language?: string }) => Promise<{ recorder: Recorder, page: Page }>;
+ openRecorder: (options?: { testIdAttributeName?: string, language?: string, __testHookFrameSelectorTimeout?: number }) => Promise<{ recorder: Recorder, page: Page }>;
runCLI: (args: string[]) => CLIMock;
};
From 7fdb4208899f619eceba4c204b23b2d546a5bc9f Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Mon, 10 Aug 2026 08:55:46 +0000
Subject: [PATCH 3/3] test(recorder): extend frame selector deadline under test
Co-authored-by: Skn0tt <14912729+Skn0tt@users.noreply.github.com>
---
packages/playwright-core/src/server/recorder.ts | 10 +++++-----
.../src/server/recorder/recorderUtils.ts | 3 ++-
tests/library/inspector/cli-codegen-3.spec.ts | 6 ++----
tests/library/inspector/inspectorTest.ts | 2 +-
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/packages/playwright-core/src/server/recorder.ts b/packages/playwright-core/src/server/recorder.ts
index e8e5b246c7186..e1461dbab79d3 100644
--- a/packages/playwright-core/src/server/recorder.ts
+++ b/packages/playwright-core/src/server/recorder.ts
@@ -46,7 +46,7 @@ import type { RegisteredListener } from '@utils/eventsHelper';
const recorderSymbol = Symbol('recorderSymbol');
type BindingSource = { frame: Frame, page: Page };
-type RecorderParams = channels.BrowserContextEnableRecorderParams & { hideToolbar?: boolean, __testHookFrameSelectorTimeout?: number };
+type RecorderParams = channels.BrowserContextEnableRecorderParams & { hideToolbar?: boolean };
export const RecorderEvent = {
PausedStateChanged: 'pausedStateChanged',
@@ -194,7 +194,7 @@ export class Recorder extends EventEmitter implements Instrume
});
await this._context.exposeBinding(progress, '__pw_recorderElementPicked', async ({ frame }, elementInfo: ElementInfo) => {
- const selector = await buildFullSelectorForFrame(progress, frame, elementInfo.selector, this._params.__testHookFrameSelectorTimeout);
+ const selector = await buildFullSelectorForFrame(progress, frame, elementInfo.selector);
this.emit(RecorderEvent.ElementPicked, { selector, ariaSnapshot: elementInfo.ariaSnapshot }, true);
});
@@ -540,15 +540,15 @@ export class Recorder extends EventEmitter implements Instrume
}
private async _performAction(progress: Progress, frame: Frame, action: actions.PerformableAction) {
- const selector = await buildFullSelectorForFrame(progress, frame, action.selector, this._params.__testHookFrameSelectorTimeout);
+ const selector = await buildFullSelectorForFrame(progress, frame, action.selector);
await performAction(progress, frame._page.mainFrame(), { ...action, selector });
}
private async _recordAction(progress: Progress, frame: Frame, action: actions.Action, preconditionSelector?: string) {
if (preconditionSelector)
- this._signalProcessor.signal(frame, { name: 'expect', selector: await buildFullSelectorForFrame(progress, frame, preconditionSelector, this._params.__testHookFrameSelectorTimeout) });
+ this._signalProcessor.signal(frame, { name: 'expect', selector: await buildFullSelectorForFrame(progress, frame, preconditionSelector) });
if ('selector' in action)
- action.selector = await buildFullSelectorForFrame(progress, frame, action.selector, this._params.__testHookFrameSelectorTimeout);
+ action.selector = await buildFullSelectorForFrame(progress, frame, action.selector);
const actionInContext: actions.ActionInContext = {
pageGuid: frame._page.guid,
action,
diff --git a/packages/playwright-core/src/server/recorder/recorderUtils.ts b/packages/playwright-core/src/server/recorder/recorderUtils.ts
index 5d1523a5def09..a29951ec63cf7 100644
--- a/packages/playwright-core/src/server/recorder/recorderUtils.ts
+++ b/packages/playwright-core/src/server/recorder/recorderUtils.ts
@@ -18,6 +18,7 @@ import { renderTitleForCall } from '@isomorphic/protocolFormatter';
import { raceAgainstDeadline } from '@isomorphic/timeoutRunner';
import { monotonicTime } from '@isomorphic/time';
import { quoteCSSAttributeValue } from '@isomorphic/stringUtils';
+import { isUnderTest } from '@utils/debug';
import { Frame } from '../frames';
import type { CallMetadata } from '../instrumentation';
@@ -28,7 +29,7 @@ function buildFullSelector(framePath: string[], selector: string) {
return [...framePath, selector].join(' >> internal:control=enter-frame >> ');
}
-export async function buildFullSelectorForFrame(progress: Progress, frame: Frame, selector: string, timeout = 2000): Promise {
+export async function buildFullSelectorForFrame(progress: Progress, frame: Frame, selector: string, timeout = isUnderTest() ? 10000 : 2000): Promise {
const framePath = await generateFrameSelector(progress, frame, timeout);
if (!frame._page.browserContext._options.pierceFrames || !framePath.length)
return buildFullSelector(framePath, selector);
diff --git a/tests/library/inspector/cli-codegen-3.spec.ts b/tests/library/inspector/cli-codegen-3.spec.ts
index 2a170b055c828..5d3852b89ce1b 100644
--- a/tests/library/inspector/cli-codegen-3.spec.ts
+++ b/tests/library/inspector/cli-codegen-3.spec.ts
@@ -1166,10 +1166,8 @@ test.describe('cli codegen with pierceFrames', () => {
await page.getByText('Hello2').click();`);
});
- test('should prepend the frame selector to disambiguate', async ({ openRecorder, server, browserName, isMac }) => {
- const { page, recorder } = await openRecorder({
- __testHookFrameSelectorTimeout: browserName === 'firefox' && isMac && process.arch === 'x64' ? 10_000 : undefined,
- });
+ test('should prepend the frame selector to disambiguate', async ({ openRecorder, server }) => {
+ const { page, recorder } = await openRecorder();
await recorder.setContentAndWait(`
diff --git a/tests/library/inspector/inspectorTest.ts b/tests/library/inspector/inspectorTest.ts
index d6e8c9b87a832..9fa145a651b01 100644
--- a/tests/library/inspector/inspectorTest.ts
+++ b/tests/library/inspector/inspectorTest.ts
@@ -27,7 +27,7 @@ export { expect } from '@playwright/test';
type CLITestArgs = {
recorderPageGetter: () => Promise;
closeRecorder: () => Promise;
- openRecorder: (options?: { testIdAttributeName?: string, language?: string, __testHookFrameSelectorTimeout?: number }) => Promise<{ recorder: Recorder, page: Page }>;
+ openRecorder: (options?: { testIdAttributeName?: string, language?: string }) => Promise<{ recorder: Recorder, page: Page }>;
runCLI: (args: string[]) => CLIMock;
};