mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
This commit is contained in:
parent
674988c633
commit
e551506c9e
@ -188,7 +188,7 @@ class RecordActionTool implements RecorderTool {
|
|||||||
return;
|
return;
|
||||||
if (this._actionInProgress(event))
|
if (this._actionInProgress(event))
|
||||||
return;
|
return;
|
||||||
if (this._consumedDueWrongTarget(event, this._hoveredModel))
|
if (this._consumedDueToNoModel(event, this._hoveredModel))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const checkbox = asCheckbox(this._recorder.deepEventTarget(event));
|
const checkbox = asCheckbox(this._recorder.deepEventTarget(event));
|
||||||
@ -283,7 +283,7 @@ class RecordActionTool implements RecorderTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Non-navigating actions are simply recorded by Playwright.
|
// Non-navigating actions are simply recorded by Playwright.
|
||||||
if (this._consumedDueWrongTarget(event, this._activeModel))
|
if (this._consumedDueWrongTarget(event))
|
||||||
return;
|
return;
|
||||||
this._recorder.delegate.recordAction?.({
|
this._recorder.delegate.recordAction?.({
|
||||||
name: 'fill',
|
name: 'fill',
|
||||||
@ -313,7 +313,7 @@ class RecordActionTool implements RecorderTool {
|
|||||||
this._expectProgrammaticKeyUp = true;
|
this._expectProgrammaticKeyUp = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this._consumedDueWrongTarget(event, this._activeModel))
|
if (this._consumedDueWrongTarget(event))
|
||||||
return;
|
return;
|
||||||
// Similarly to click, trigger checkbox on key event, not input.
|
// Similarly to click, trigger checkbox on key event, not input.
|
||||||
if (event.key === ' ') {
|
if (event.key === ' ') {
|
||||||
@ -373,7 +373,7 @@ class RecordActionTool implements RecorderTool {
|
|||||||
const nodeName = target.nodeName;
|
const nodeName = target.nodeName;
|
||||||
if (nodeName === 'SELECT' || nodeName === 'OPTION')
|
if (nodeName === 'SELECT' || nodeName === 'OPTION')
|
||||||
return true;
|
return true;
|
||||||
if (nodeName === 'INPUT' && ['date', 'range'].includes((target as HTMLInputElement).type))
|
if (nodeName === 'INPUT' && ['date'].includes((target as HTMLInputElement).type))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -387,8 +387,15 @@ class RecordActionTool implements RecorderTool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _consumedDueWrongTarget(event: Event, model: HighlightModel | null): boolean {
|
private _consumedDueToNoModel(event: Event, model: HighlightModel | null): boolean {
|
||||||
if (model && model.elements[0] === this._recorder.deepEventTarget(event))
|
if (model)
|
||||||
|
return false;
|
||||||
|
consumeEvent(event);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _consumedDueWrongTarget(event: Event): boolean {
|
||||||
|
if (this._activeModel && this._activeModel.elements[0] === this._recorder.deepEventTarget(event))
|
||||||
return false;
|
return false;
|
||||||
consumeEvent(event);
|
consumeEvent(event);
|
||||||
return true;
|
return true;
|
||||||
|
@ -746,32 +746,4 @@ await page.GetByText("Click me").ClickAsync(new LocatorClickOptions
|
|||||||
Button = MouseButton.Middle,
|
Button = MouseButton.Middle,
|
||||||
});`);
|
});`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should record slider', async ({ page, openRecorder }) => {
|
|
||||||
const recorder = await openRecorder();
|
|
||||||
|
|
||||||
await recorder.setContentAndWait(`<input type="range" min="0" max="10" value="5">`);
|
|
||||||
|
|
||||||
const dragSlider = async () => {
|
|
||||||
await page.locator('input').focus();
|
|
||||||
const { x, y, width, height } = await page.locator('input').boundingBox();
|
|
||||||
await page.mouse.move(x + width / 2, y + height / 2);
|
|
||||||
await page.mouse.down();
|
|
||||||
await page.mouse.move(x + width, y + height / 2);
|
|
||||||
await page.mouse.up();
|
|
||||||
};
|
|
||||||
|
|
||||||
const [sources] = await Promise.all([
|
|
||||||
recorder.waitForOutput('JavaScript', 'fill'),
|
|
||||||
dragSlider(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await expect(page.locator('input')).toHaveValue('10');
|
|
||||||
|
|
||||||
expect(sources.get('JavaScript')!.text).toContain(`
|
|
||||||
await page.getByRole('slider').fill('10');`);
|
|
||||||
|
|
||||||
expect(sources.get('JavaScript')!.text).not.toContain(`
|
|
||||||
await page.getByRole('slider').click();`);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user