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.
Drag right by 100 pixels
Section titled “Drag right by 100 pixels”describe('Test script', function () { it('Drag element to the right', async () => { const element = await gf.get('.draggable-item'); await element.dragBy(100, 0); });});Drag down and to the right
Section titled “Drag down and to the right”describe('Test script', function () { it('Drag element diagonally', async () => { const element = await gf.get('.draggable-item'); await element.dragBy(50, 75); });});Drag with negative offsets (up and left)
Section titled “Drag with negative offsets (up and left)”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); });});