feat(dragAndDrop): page.dragAndDrop (#6910)

This commit is contained in:
Joel Einbinder 2021-07-19 12:42:55 -05:00 committed by GitHub
parent d72efbe181
commit 56ada374df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 229 additions and 48 deletions

View file

@ -374,6 +374,20 @@ Optional event-specific initialization properties.
### option: Frame.dispatchEvent.timeout = %%-input-timeout-%% ### option: Frame.dispatchEvent.timeout = %%-input-timeout-%%
## async method: Frame.dragAndDrop
### param: Frame.dragAndDrop.source = %%-input-source-%%
### param: Frame.dragAndDrop.target = %%-input-target-%%
### option: Frame.dragAndDrop.force = %%-input-force-%%
### option: Frame.dragAndDrop.noWaitAfter = %%-input-no-wait-after-%%
### option: Frame.dragAndDrop.timeout = %%-input-timeout-%%
### option: Frame.dragAndDrop.trial = %%-input-trial-%%
## async method: Frame.evalOnSelector ## async method: Frame.evalOnSelector
* langs: * langs:
- alias-python: eval_on_selector - alias-python: eval_on_selector

View file

@ -811,6 +811,20 @@ Optional event-specific initialization properties.
### option: Page.dispatchEvent.timeout = %%-input-timeout-%% ### option: Page.dispatchEvent.timeout = %%-input-timeout-%%
## async method: Page.dragAndDrop
### param: Page.dragAndDrop.source = %%-input-source-%%
### param: Page.dragAndDrop.target = %%-input-target-%%
### option: Page.dragAndDrop.force = %%-input-force-%%
### option: Page.dragAndDrop.noWaitAfter = %%-input-no-wait-after-%%
### option: Page.dragAndDrop.timeout = %%-input-timeout-%%
### option: Page.dragAndDrop.trial = %%-input-trial-%%
## async method: Page.emulateMedia ## async method: Page.emulateMedia
This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media feature, using the `colorScheme` argument. This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media feature, using the `colorScheme` argument.

View file

@ -44,7 +44,17 @@ Whether to bypass the [actionability](./actionability.md) checks. Defaults to `f
## input-selector ## input-selector
- `selector` <[string]> - `selector` <[string]>
A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See
[working with selectors](./selectors.md) for more details.
## input-source
- `source` <[string]>
A selector to search for an element to drag. If there are multiple elements satisfying the selector, the first will be used. See
[working with selectors](./selectors.md) for more details.
## input-target
- `target` <[string]>
A selector to search for an element to drop onto. If there are multiple elements satisfying the selector, the first will be used. See
[working with selectors](./selectors.md) for more details. [working with selectors](./selectors.md) for more details.
## input-position ## input-position

View file

@ -298,6 +298,12 @@ export class Frame extends ChannelOwner<channels.FrameChannel, channels.FrameIni
}); });
} }
async dragAndDrop(source: string, target: string, options: channels.FrameDragAndDropOptions = {}) {
return this._wrapApiCall(async (channel: channels.FrameChannel) => {
return await channel.dragAndDrop({ source, target, ...options });
});
}
async tap(selector: string, options: channels.FrameTapOptions = {}) { async tap(selector: string, options: channels.FrameTapOptions = {}) {
return this._wrapApiCall(async (channel: channels.FrameChannel) => { return this._wrapApiCall(async (channel: channels.FrameChannel) => {
return await channel.tap({ selector, ...options }); return await channel.tap({ selector, ...options });

View file

@ -505,6 +505,10 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
return this._mainFrame.click(selector, options); return this._mainFrame.click(selector, options);
} }
async dragAndDrop(source: string, target: string, options?: channels.FrameDragAndDropOptions) {
return this._mainFrame.dragAndDrop(source, target, options);
}
async dblclick(selector: string, options?: channels.FrameDblclickOptions) { async dblclick(selector: string, options?: channels.FrameDblclickOptions) {
return this._mainFrame.dblclick(selector, options); return this._mainFrame.dblclick(selector, options);
} }

View file

@ -123,6 +123,10 @@ export class FrameDispatcher extends Dispatcher<Frame, channels.FrameInitializer
return await this._frame.dblclick(metadata, params.selector, params); return await this._frame.dblclick(metadata, params.selector, params);
} }
async dragAndDrop(params: channels.FrameDragAndDropParams, metadata: CallMetadata): Promise<void> {
return await this._frame.dragAndDrop(metadata, params.source, params.target, params);
}
async tap(params: channels.FrameTapParams, metadata: CallMetadata): Promise<void> { async tap(params: channels.FrameTapParams, metadata: CallMetadata): Promise<void> {
return await this._frame.tap(metadata, params.selector, params); return await this._frame.tap(metadata, params.selector, params);
} }

View file

@ -1310,6 +1310,7 @@ export interface FrameChannel extends Channel {
check(params: FrameCheckParams, metadata?: Metadata): Promise<FrameCheckResult>; check(params: FrameCheckParams, metadata?: Metadata): Promise<FrameCheckResult>;
click(params: FrameClickParams, metadata?: Metadata): Promise<FrameClickResult>; click(params: FrameClickParams, metadata?: Metadata): Promise<FrameClickResult>;
content(params?: FrameContentParams, metadata?: Metadata): Promise<FrameContentResult>; content(params?: FrameContentParams, metadata?: Metadata): Promise<FrameContentResult>;
dragAndDrop(params: FrameDragAndDropParams, metadata?: Metadata): Promise<FrameDragAndDropResult>;
dblclick(params: FrameDblclickParams, metadata?: Metadata): Promise<FrameDblclickResult>; dblclick(params: FrameDblclickParams, metadata?: Metadata): Promise<FrameDblclickResult>;
dispatchEvent(params: FrameDispatchEventParams, metadata?: Metadata): Promise<FrameDispatchEventResult>; dispatchEvent(params: FrameDispatchEventParams, metadata?: Metadata): Promise<FrameDispatchEventResult>;
evaluateExpression(params: FrameEvaluateExpressionParams, metadata?: Metadata): Promise<FrameEvaluateExpressionResult>; evaluateExpression(params: FrameEvaluateExpressionParams, metadata?: Metadata): Promise<FrameEvaluateExpressionResult>;
@ -1448,6 +1449,21 @@ export type FrameContentOptions = {};
export type FrameContentResult = { export type FrameContentResult = {
value: string, value: string,
}; };
export type FrameDragAndDropParams = {
source: string,
target: string,
force?: boolean,
noWaitAfter?: boolean,
timeout?: number,
trial?: boolean,
};
export type FrameDragAndDropOptions = {
force?: boolean,
noWaitAfter?: boolean,
timeout?: number,
trial?: boolean,
};
export type FrameDragAndDropResult = void;
export type FrameDblclickParams = { export type FrameDblclickParams = {
selector: string, selector: string,
force?: boolean, force?: boolean,

View file

@ -1177,6 +1177,15 @@ Frame:
returns: returns:
value: string value: string
dragAndDrop:
parameters:
source: string
target: string
force: boolean?
noWaitAfter: boolean?
timeout: number?
trial: boolean?
dblclick: dblclick:
parameters: parameters:
selector: string selector: string

View file

@ -587,6 +587,14 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
trial: tOptional(tBoolean), trial: tOptional(tBoolean),
}); });
scheme.FrameContentParams = tOptional(tObject({})); scheme.FrameContentParams = tOptional(tObject({}));
scheme.FrameDragAndDropParams = tObject({
source: tString,
target: tString,
force: tOptional(tBoolean),
noWaitAfter: tOptional(tBoolean),
timeout: tOptional(tNumber),
trial: tOptional(tBoolean),
});
scheme.FrameDblclickParams = tObject({ scheme.FrameDblclickParams = tObject({
selector: tString, selector: tString,
force: tOptional(tBoolean), force: tOptional(tBoolean),

View file

@ -982,6 +982,30 @@ export class Frame extends SdkObject {
}, this._page._timeoutSettings.timeout(options)); }, this._page._timeoutSettings.timeout(options));
} }
async dragAndDrop(metadata: CallMetadata, source: string, target: string, options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) {
const controller = new ProgressController(metadata, this);
await controller.run(async progress => {
await dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, async handle => {
return handle._retryPointerAction(progress, 'move and down', false, async point => {
await this._page.mouse.move(point.x, point.y);
await this._page.mouse.down();
}, {
...options,
timeout: progress.timeUntilDeadline(),
});
}));
await dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, async handle => {
return handle._retryPointerAction(progress, 'move and up', false, async point => {
await this._page.mouse.move(point.x, point.y);
await this._page.mouse.up();
}, {
...options,
timeout: progress.timeUntilDeadline(),
});
}));
}, this._page._timeoutSettings.timeout(options));
}
async tap(metadata: CallMetadata, selector: string, options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) { async tap(metadata: CallMetadata, selector: string, options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) {
const controller = new ProgressController(metadata, this); const controller = new ProgressController(metadata, this);
return controller.run(async progress => { return controller.run(async progress => {

View file

@ -228,6 +228,12 @@ it.describe('Drag and drop', () => {
expect(await page.$eval('#target', target => target.contains(document.querySelector('#source')))).toBe(true); // could not find source in target expect(await page.$eval('#target', target => target.contains(document.querySelector('#source')))).toBe(true); // could not find source in target
}); });
it('should work with the helper method', async ({page, server}) => {
await page.goto(server.PREFIX + '/drag-n-drop.html');
await page.dragAndDrop('#source', '#target');
expect(await page.$eval('#target', target => target.contains(document.querySelector('#source')))).toBe(true); // could not find source in target
});
async function trackEvents(target: ElementHandle) { async function trackEvents(target: ElementHandle) {
const eventsHandle = await target.evaluateHandle(target => { const eventsHandle = await target.evaluateHandle(target => {
const events: string[] = []; const events: string[] = [];

160
types/types.d.ts vendored
View file

@ -1125,7 +1125,7 @@ export interface Page {
* zero timeout disables this. * zero timeout disables this.
* *
* Shortcut for main frame's [frame.check(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-check). * Shortcut for main frame's [frame.check(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-check).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
check(selector: string, options?: { check(selector: string, options?: {
@ -1180,7 +1180,7 @@ export interface Page {
* zero timeout disables this. * zero timeout disables this.
* *
* Shortcut for main frame's [frame.click(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-click). * Shortcut for main frame's [frame.click(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-click).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
click(selector: string, options?: { click(selector: string, options?: {
@ -1295,7 +1295,7 @@ export interface Page {
* *
* Shortcut for main frame's * Shortcut for main frame's
* [frame.dblclick(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-dblclick). * [frame.dblclick(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-dblclick).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
dblclick(selector: string, options?: { dblclick(selector: string, options?: {
@ -1381,7 +1381,7 @@ export interface Page {
* await page.dispatchEvent('#source', 'dragstart', { dataTransfer }); * await page.dispatchEvent('#source', 'dragstart', { dataTransfer });
* ``` * ```
* *
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param type DOM event type: `"click"`, `"dragstart"`, etc. * @param type DOM event type: `"click"`, `"dragstart"`, etc.
* @param eventInit Optional event-specific initialization properties. * @param eventInit Optional event-specific initialization properties.
* @param options * @param options
@ -1396,6 +1396,39 @@ export interface Page {
timeout?: number; timeout?: number;
}): Promise<void>; }): Promise<void>;
/**
* @param source
* @param target
* @param options
*/
dragAndDrop(source: string, target: string, options?: {
/**
* Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
*/
force?: boolean;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to `false`.
*/
noWaitAfter?: boolean;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
* using the
* [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods.
*/
timeout?: number;
/**
* When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to
* `false`. Useful to wait until the element is ready for the action without performing it.
*/
trial?: boolean;
}): Promise<void>;
/** /**
* This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media * This method changes the `CSS media type` through the `media` argument, and/or the `'prefers-colors-scheme'` media
* feature, using the `colorScheme` argument. * feature, using the `colorScheme` argument.
@ -1508,7 +1541,7 @@ export interface Page {
* *
* Shortcut for main frame's * Shortcut for main frame's
* [frame.fill(selector, value[, options])](https://playwright.dev/docs/api/class-frame#frame-fill). * [frame.fill(selector, value[, options])](https://playwright.dev/docs/api/class-frame#frame-fill).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element. * @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
* @param options * @param options
*/ */
@ -1539,7 +1572,7 @@ export interface Page {
* waits until a matching element appears in the DOM. * waits until a matching element appears in the DOM.
* *
* Shortcut for main frame's [frame.focus(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-focus). * Shortcut for main frame's [frame.focus(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-focus).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
focus(selector: string, options?: { focus(selector: string, options?: {
@ -1584,7 +1617,7 @@ export interface Page {
/** /**
* Returns element attribute value. * Returns element attribute value.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param name Attribute name to get the value for. * @param name Attribute name to get the value for.
* @param options * @param options
*/ */
@ -1717,7 +1750,7 @@ export interface Page {
* zero timeout disables this. * zero timeout disables this.
* *
* Shortcut for main frame's [frame.hover(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-hover). * Shortcut for main frame's [frame.hover(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-hover).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
hover(selector: string, options?: { hover(selector: string, options?: {
@ -1759,7 +1792,7 @@ export interface Page {
/** /**
* Returns `element.innerHTML`. * Returns `element.innerHTML`.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
innerHTML(selector: string, options?: { innerHTML(selector: string, options?: {
@ -1774,7 +1807,7 @@ export interface Page {
/** /**
* Returns `element.innerText`. * Returns `element.innerText`.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
innerText(selector: string, options?: { innerText(selector: string, options?: {
@ -1789,7 +1822,7 @@ export interface Page {
/** /**
* Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements. * Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
inputValue(selector: string, options?: { inputValue(selector: string, options?: {
@ -1804,7 +1837,7 @@ export interface Page {
/** /**
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input. * Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isChecked(selector: string, options?: { isChecked(selector: string, options?: {
@ -1824,7 +1857,7 @@ export interface Page {
/** /**
* Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled). * Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isDisabled(selector: string, options?: { isDisabled(selector: string, options?: {
@ -1839,7 +1872,7 @@ export interface Page {
/** /**
* Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable). * Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isEditable(selector: string, options?: { isEditable(selector: string, options?: {
@ -1854,7 +1887,7 @@ export interface Page {
/** /**
* Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled). * Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isEnabled(selector: string, options?: { isEnabled(selector: string, options?: {
@ -1870,7 +1903,7 @@ export interface Page {
/** /**
* Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not * Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not
* match any elements is considered hidden. * match any elements is considered hidden.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isHidden(selector: string, options?: { isHidden(selector: string, options?: {
@ -1886,7 +1919,7 @@ export interface Page {
/** /**
* Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not match any elements is * Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not match any elements is
* considered not visible. * considered not visible.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isVisible(selector: string, options?: { isVisible(selector: string, options?: {
@ -2102,7 +2135,7 @@ export interface Page {
* await browser.close(); * await browser.close();
* ``` * ```
* *
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`. * @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
* @param options * @param options
*/ */
@ -2236,7 +2269,7 @@ export interface Page {
* *
* Shortcut for main frame's * Shortcut for main frame's
* [frame.selectOption(selector, values[, options])](https://playwright.dev/docs/api/class-frame#frame-select-option). * [frame.selectOption(selector, values[, options])](https://playwright.dev/docs/api/class-frame#frame-select-option).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param values Options to select. If the `<select>` has the `multiple` attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are equivalent to `{value:'string'}`. Option * @param values Options to select. If the `<select>` has the `multiple` attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are equivalent to `{value:'string'}`. Option
* is considered matching if all specified properties match. * is considered matching if all specified properties match.
* @param options * @param options
@ -2364,7 +2397,7 @@ export interface Page {
* *
* Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they * Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
* are resolved relative to the the current working directory. For empty array, clears the selected files. * are resolved relative to the the current working directory. For empty array, clears the selected files.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param files * @param files
* @param options * @param options
*/ */
@ -2463,7 +2496,7 @@ export interface Page {
* `hasTouch` option of the browser context be set to true. * `hasTouch` option of the browser context be set to true.
* *
* Shortcut for main frame's [frame.tap(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-tap). * Shortcut for main frame's [frame.tap(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-tap).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
tap(selector: string, options?: { tap(selector: string, options?: {
@ -2512,7 +2545,7 @@ export interface Page {
/** /**
* Returns `element.textContent`. * Returns `element.textContent`.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
textContent(selector: string, options?: { textContent(selector: string, options?: {
@ -2548,7 +2581,7 @@ export interface Page {
* *
* Shortcut for main frame's * Shortcut for main frame's
* [frame.type(selector, text[, options])](https://playwright.dev/docs/api/class-frame#frame-type). * [frame.type(selector, text[, options])](https://playwright.dev/docs/api/class-frame#frame-type).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param text A text to type into a focused element. * @param text A text to type into a focused element.
* @param options * @param options
*/ */
@ -2591,7 +2624,7 @@ export interface Page {
* *
* Shortcut for main frame's * Shortcut for main frame's
* [frame.uncheck(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-uncheck). * [frame.uncheck(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-uncheck).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
uncheck(selector: string, options?: { uncheck(selector: string, options?: {
@ -3385,7 +3418,7 @@ export interface Frame {
* *
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError]. Passing * When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError]. Passing
* zero timeout disables this. * zero timeout disables this.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
check(selector: string, options?: { check(selector: string, options?: {
@ -3440,7 +3473,7 @@ export interface Frame {
* *
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError]. Passing * When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError]. Passing
* zero timeout disables this. * zero timeout disables this.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
click(selector: string, options?: { click(selector: string, options?: {
@ -3522,7 +3555,7 @@ export interface Frame {
* zero timeout disables this. * zero timeout disables this.
* *
* > NOTE: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event. * > NOTE: `frame.dblclick()` dispatches two `click` events and a single `dblclick` event.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
dblclick(selector: string, options?: { dblclick(selector: string, options?: {
@ -3608,7 +3641,7 @@ export interface Frame {
* await frame.dispatchEvent('#source', 'dragstart', { dataTransfer }); * await frame.dispatchEvent('#source', 'dragstart', { dataTransfer });
* ``` * ```
* *
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param type DOM event type: `"click"`, `"dragstart"`, etc. * @param type DOM event type: `"click"`, `"dragstart"`, etc.
* @param eventInit Optional event-specific initialization properties. * @param eventInit Optional event-specific initialization properties.
* @param options * @param options
@ -3623,6 +3656,39 @@ export interface Frame {
timeout?: number; timeout?: number;
}): Promise<void>; }): Promise<void>;
/**
* @param source
* @param target
* @param options
*/
dragAndDrop(source: string, target: string, options?: {
/**
* Whether to bypass the [actionability](https://playwright.dev/docs/actionability) checks. Defaults to `false`.
*/
force?: boolean;
/**
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
* inaccessible pages. Defaults to `false`.
*/
noWaitAfter?: boolean;
/**
* Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by
* using the
* [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods.
*/
timeout?: number;
/**
* When set, this method only performs the [actionability](https://playwright.dev/docs/actionability) checks and skips the action. Defaults to
* `false`. Useful to wait until the element is ready for the action without performing it.
*/
trial?: boolean;
}): Promise<void>;
/** /**
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the * This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the
* element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input * element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
@ -3635,7 +3701,7 @@ export interface Frame {
* *
* To send fine-grained keyboard events, use * To send fine-grained keyboard events, use
* [frame.type(selector, text[, options])](https://playwright.dev/docs/api/class-frame#frame-type). * [frame.type(selector, text[, options])](https://playwright.dev/docs/api/class-frame#frame-type).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element. * @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
* @param options * @param options
*/ */
@ -3664,7 +3730,7 @@ export interface Frame {
/** /**
* This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method * This method fetches an element with `selector` and focuses it. If there's no element matching `selector`, the method
* waits until a matching element appears in the DOM. * waits until a matching element appears in the DOM.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
focus(selector: string, options?: { focus(selector: string, options?: {
@ -3697,7 +3763,7 @@ export interface Frame {
/** /**
* Returns element attribute value. * Returns element attribute value.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param name Attribute name to get the value for. * @param name Attribute name to get the value for.
* @param options * @param options
*/ */
@ -3771,7 +3837,7 @@ export interface Frame {
* *
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError]. Passing * When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError]. Passing
* zero timeout disables this. * zero timeout disables this.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
hover(selector: string, options?: { hover(selector: string, options?: {
@ -3813,7 +3879,7 @@ export interface Frame {
/** /**
* Returns `element.innerHTML`. * Returns `element.innerHTML`.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
innerHTML(selector: string, options?: { innerHTML(selector: string, options?: {
@ -3828,7 +3894,7 @@ export interface Frame {
/** /**
* Returns `element.innerText`. * Returns `element.innerText`.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
innerText(selector: string, options?: { innerText(selector: string, options?: {
@ -3843,7 +3909,7 @@ export interface Frame {
/** /**
* Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements. * Returns `input.value` for the selected `<input>` or `<textarea>` element. Throws for non-input elements.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
inputValue(selector: string, options?: { inputValue(selector: string, options?: {
@ -3858,7 +3924,7 @@ export interface Frame {
/** /**
* Returns whether the element is checked. Throws if the element is not a checkbox or radio input. * Returns whether the element is checked. Throws if the element is not a checkbox or radio input.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isChecked(selector: string, options?: { isChecked(selector: string, options?: {
@ -3878,7 +3944,7 @@ export interface Frame {
/** /**
* Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled). * Returns whether the element is disabled, the opposite of [enabled](https://playwright.dev/docs/actionability#enabled).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isDisabled(selector: string, options?: { isDisabled(selector: string, options?: {
@ -3893,7 +3959,7 @@ export interface Frame {
/** /**
* Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable). * Returns whether the element is [editable](https://playwright.dev/docs/actionability#editable).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isEditable(selector: string, options?: { isEditable(selector: string, options?: {
@ -3908,7 +3974,7 @@ export interface Frame {
/** /**
* Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled). * Returns whether the element is [enabled](https://playwright.dev/docs/actionability#enabled).
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isEnabled(selector: string, options?: { isEnabled(selector: string, options?: {
@ -3924,7 +3990,7 @@ export interface Frame {
/** /**
* Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not * Returns whether the element is hidden, the opposite of [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not
* match any elements is considered hidden. * match any elements is considered hidden.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isHidden(selector: string, options?: { isHidden(selector: string, options?: {
@ -3940,7 +4006,7 @@ export interface Frame {
/** /**
* Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not match any elements is * Returns whether the element is [visible](https://playwright.dev/docs/actionability#visible). `selector` that does not match any elements is
* considered not visible. * considered not visible.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
isVisible(selector: string, options?: { isVisible(selector: string, options?: {
@ -3989,7 +4055,7 @@ export interface Frame {
* *
* Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the * Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
* modifier, modifier is pressed and being held while the subsequent key is being pressed. * modifier, modifier is pressed and being held while the subsequent key is being pressed.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`. * @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
* @param options * @param options
*/ */
@ -4125,7 +4191,7 @@ export interface Frame {
* *
* Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they * Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they
* are resolved relative to the the current working directory. For empty array, clears the selected files. * are resolved relative to the the current working directory. For empty array, clears the selected files.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param files * @param files
* @param options * @param options
*/ */
@ -4190,7 +4256,7 @@ export interface Frame {
* zero timeout disables this. * zero timeout disables this.
* *
* > NOTE: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true. * > NOTE: `frame.tap()` requires that the `hasTouch` option of the browser context be set to true.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
tap(selector: string, options?: { tap(selector: string, options?: {
@ -4239,7 +4305,7 @@ export interface Frame {
/** /**
* Returns `element.textContent`. * Returns `element.textContent`.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
textContent(selector: string, options?: { textContent(selector: string, options?: {
@ -4270,7 +4336,7 @@ export interface Frame {
* await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user * await frame.type('#mytextarea', 'World', {delay: 100}); // Types slower, like a user
* ``` * ```
* *
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param text A text to type into a focused element. * @param text A text to type into a focused element.
* @param options * @param options
*/ */
@ -4310,7 +4376,7 @@ export interface Frame {
* *
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError]. Passing * When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError]. Passing
* zero timeout disables this. * zero timeout disables this.
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details. * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
* @param options * @param options
*/ */
uncheck(selector: string, options?: { uncheck(selector: string, options?: {