Skip to content

element.dragBy

element.dragBy(deltaX?: number, deltaY?: number): Promise<void>

Section titled “element.dragBy(deltaX?: number, deltaY?: number): Promise<void>”

Drags the element by the specified offsets relative to the element’s center.

Performs a pointer drag from the center of the current element to a new position calculated by adding the specified offsets to the element’s center coordinates. This is useful for dragging elements by a relative distance rather than to an absolute position or target element.

  • deltaX: (Optional) Horizontal offset in pixels to move from the element’s center. Defaults to 0.
  • deltaY: (Optional) Vertical offset in pixels to move from the element’s center. Defaults to 0.
  • Returns a promise that resolves once the drag sequence (press → move → release) completes.
describe('Test script', function () {
it('Drag element to the right', async () => {
const element = await gf.get('.draggable-item');
await element.dragBy(100, 0);
});
});
describe('Test script', function () {
it('Drag element diagonally', async () => {
const element = await gf.get('.draggable-item');
await element.dragBy(50, 75);
});
});
describe('Test script', function () {
it('Drag element up and to the left', async () => {
const element = await gf.get('.draggable-item');
await element.dragBy(-100, -50);
});
});