Skip to content

Commit e551506

Browse files
authored
Revert "feat(codegen): add range input recording support (#28767)" (#29069)
1 parent 674988c commit e551506

File tree

2 files changed

+13
-34
lines changed

2 files changed

+13
-34
lines changed

packages/playwright-core/src/server/injected/recorder.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class RecordActionTool implements RecorderTool {
188188
return;
189189
if (this._actionInProgress(event))
190190
return;
191-
if (this._consumedDueWrongTarget(event, this._hoveredModel))
191+
if (this._consumedDueToNoModel(event, this._hoveredModel))
192192
return;
193193

194194
const checkbox = asCheckbox(this._recorder.deepEventTarget(event));
@@ -283,7 +283,7 @@ class RecordActionTool implements RecorderTool {
283283
}
284284

285285
// Non-navigating actions are simply recorded by Playwright.
286-
if (this._consumedDueWrongTarget(event, this._activeModel))
286+
if (this._consumedDueWrongTarget(event))
287287
return;
288288
this._recorder.delegate.recordAction?.({
289289
name: 'fill',
@@ -313,7 +313,7 @@ class RecordActionTool implements RecorderTool {
313313
this._expectProgrammaticKeyUp = true;
314314
return;
315315
}
316-
if (this._consumedDueWrongTarget(event, this._activeModel))
316+
if (this._consumedDueWrongTarget(event))
317317
return;
318318
// Similarly to click, trigger checkbox on key event, not input.
319319
if (event.key === ' ') {
@@ -373,7 +373,7 @@ class RecordActionTool implements RecorderTool {
373373
const nodeName = target.nodeName;
374374
if (nodeName === 'SELECT' || nodeName === 'OPTION')
375375
return true;
376-
if (nodeName === 'INPUT' && ['date', 'range'].includes((target as HTMLInputElement).type))
376+
if (nodeName === 'INPUT' && ['date'].includes((target as HTMLInputElement).type))
377377
return true;
378378
return false;
379379
}
@@ -387,8 +387,15 @@ class RecordActionTool implements RecorderTool {
387387
return false;
388388
}
389389

390-
private _consumedDueWrongTarget(event: Event, model: HighlightModel | null): boolean {
391-
if (model && model.elements[0] === this._recorder.deepEventTarget(event))
390+
private _consumedDueToNoModel(event: Event, model: HighlightModel | null): boolean {
391+
if (model)
392+
return false;
393+
consumeEvent(event);
394+
return true;
395+
}
396+
397+
private _consumedDueWrongTarget(event: Event): boolean {
398+
if (this._activeModel && this._activeModel.elements[0] === this._recorder.deepEventTarget(event))
392399
return false;
393400
consumeEvent(event);
394401
return true;

tests/library/inspector/cli-codegen-1.spec.ts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -746,32 +746,4 @@ await page.GetByText("Click me").ClickAsync(new LocatorClickOptions
746746
Button = MouseButton.Middle,
747747
});`);
748748
});
749-
750-
test('should record slider', async ({ page, openRecorder }) => {
751-
const recorder = await openRecorder();
752-
753-
await recorder.setContentAndWait(`<input type="range" min="0" max="10" value="5">`);
754-
755-
const dragSlider = async () => {
756-
await page.locator('input').focus();
757-
const { x, y, width, height } = await page.locator('input').boundingBox();
758-
await page.mouse.move(x + width / 2, y + height / 2);
759-
await page.mouse.down();
760-
await page.mouse.move(x + width, y + height / 2);
761-
await page.mouse.up();
762-
};
763-
764-
const [sources] = await Promise.all([
765-
recorder.waitForOutput('JavaScript', 'fill'),
766-
dragSlider(),
767-
]);
768-
769-
await expect(page.locator('input')).toHaveValue('10');
770-
771-
expect(sources.get('JavaScript')!.text).toContain(`
772-
await page.getByRole('slider').fill('10');`);
773-
774-
expect(sources.get('JavaScript')!.text).not.toContain(`
775-
await page.getByRole('slider').click();`);
776-
});
777749
});

0 commit comments

Comments
 (0)