Skip to content

Commit

Permalink
fix: add optional delay time in the browser drag option
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 committed Oct 6, 2020
1 parent cf5ff6a commit 13be543
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion test/functional/page_objects/discover_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider

await browser.dragAndDrop(
{ location: el, offset: { x: -300, y: 20 } },
{ location: el, offset: { x: -100, y: 30 } }
{ location: el, offset: { x: -100, y: 30 } },
200
);
}

Expand Down
12 changes: 10 additions & 2 deletions test/functional/services/common/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
*
* @param {{element: WebElementWrapper | {x: number, y: number}, offset: {x: number, y: number}}} from
* @param {{element: WebElementWrapper | {x: number, y: number}, offset: {x: number, y: number}}} to
* @param delay in ms
* @return {Promise<void>}
*/
public async dragAndDrop(
from: { offset?: { x: any; y: any }; location: any },
to: { offset?: { x: any; y: any }; location: any }
to: { offset?: { x: any; y: any }; location: any },
delay = 0
) {
// The offset should be specified in pixels relative to the center of the element's bounding box
const getW3CPoint = (data: any) => {
Expand All @@ -237,7 +239,13 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
const startPoint = getW3CPoint(from);
const endPoint = getW3CPoint(to);
await this.getActions().move({ x: 0, y: 0 }).perform();
return await this.getActions().move(startPoint).press().move(endPoint).release().perform();
return await this.getActions()
.move(startPoint)
.press()
.pause(delay)
.move(endPoint)
.release()
.perform();
}

/**
Expand Down

0 comments on commit 13be543

Please sign in to comment.