Skip to content

Commit

Permalink
source and target
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelEinbinder committed Jul 19, 2021
1 parent 2b201ff commit 91bd41e
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 76 deletions.
8 changes: 4 additions & 4 deletions docs/src/api/class-frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,11 @@ Optional event-specific initialization properties.
### option: Frame.dispatchEvent.timeout = %%-input-timeout-%%

## async method: Frame.dragAndDrop
### param: Frame.dragAndDrop.selector1
- `selector1` <[string]>

### param: Frame.dragAndDrop.selector2
- `selector2` <[string]>
### 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-%%
Expand Down
8 changes: 4 additions & 4 deletions docs/src/api/class-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,11 @@ Optional event-specific initialization properties.
### option: Page.dispatchEvent.timeout = %%-input-timeout-%%

## async method: Page.dragAndDrop
### param: Page.dragAndDrop.selector1
- `selector1` <[string]>

### param: Page.dragAndDrop.selector2
- `selector2` <[string]>
### 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-%%
Expand Down
12 changes: 11 additions & 1 deletion docs/src/api/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,17 @@ Whether to bypass the [actionability](./actionability.md) checks. Defaults to `f
## input-selector
- `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.

## input-position
Expand Down
4 changes: 2 additions & 2 deletions src/client/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,9 @@ export class Frame extends ChannelOwner<channels.FrameChannel, channels.FrameIni
});
}

async dragAndDrop(selector1: string, selector2: string, options: channels.FrameDragAndDropOptions = {}) {
async dragAndDrop(source: string, target: string, options: channels.FrameDragAndDropOptions = {}) {
return this._wrapApiCall(async (channel: channels.FrameChannel) => {
return await channel.dragAndDrop({ selector1, selector2, ...options });
return await channel.dragAndDrop({ source, target, ...options });
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/client/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ export class Page extends ChannelOwner<channels.PageChannel, channels.PageInitia
return this._mainFrame.click(selector, options);
}

async dragAndDrop(selector1: string, selector2: string, options?: channels.FrameDragAndDropOptions) {
return this._mainFrame.dragAndDrop(selector1, selector2, options);
async dragAndDrop(source: string, target: string, options?: channels.FrameDragAndDropOptions) {
return this._mainFrame.dragAndDrop(source, target, options);
}

async dblclick(selector: string, options?: channels.FrameDblclickOptions) {
Expand Down
2 changes: 1 addition & 1 deletion src/dispatchers/frameDispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class FrameDispatcher extends Dispatcher<Frame, channels.FrameInitializer
}

async dragAndDrop(params: channels.FrameDragAndDropParams, metadata: CallMetadata): Promise<void> {
return await this._frame.dragAndDrop(metadata, params.selector1, params.selector2, params);
return await this._frame.dragAndDrop(metadata, params.source, params.target, params);
}

async tap(params: channels.FrameTapParams, metadata: CallMetadata): Promise<void> {
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1450,8 +1450,8 @@ export type FrameContentResult = {
value: string,
};
export type FrameDragAndDropParams = {
selector1: string,
selector2: string,
source: string,
target: string,
force?: boolean,
noWaitAfter?: boolean,
timeout?: number,
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1179,8 +1179,8 @@ Frame:

dragAndDrop:
parameters:
selector1: string
selector2: string
source: string
target: string
force: boolean?
noWaitAfter: boolean?
timeout: number?
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,8 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
});
scheme.FrameContentParams = tOptional(tObject({}));
scheme.FrameDragAndDropParams = tObject({
selector1: tString,
selector2: tString,
source: tString,
target: tString,
force: tOptional(tBoolean),
noWaitAfter: tOptional(tBoolean),
timeout: tOptional(tNumber),
Expand Down
6 changes: 3 additions & 3 deletions src/server/frames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,10 +982,10 @@ export class Frame extends SdkObject {
}, this._page._timeoutSettings.timeout(options));
}

async dragAndDrop(metadata: CallMetadata, selector1: string, selector2: string, options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) {
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, selector1, async handle => {
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();
Expand All @@ -994,7 +994,7 @@ export class Frame extends SdkObject {
timeout: progress.timeUntilDeadline(),
});
}));
await dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector2, async handle => {
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();
Expand Down
Loading

0 comments on commit 91bd41e

Please sign in to comment.