/
githubmirror
/
ionic
Обзор
Документация
Войти
/
githubmirror
/
ionic
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular/test/base/e2e/utils/drag-utils.ts
39 строк
1 KB
Brandy Smith
test(angular): migrate to playwright (#30594)
05 авг 2025, 16:58
Не верифицирован
05 авг 2025, 16:58
05026c5
Код
Авторство
О чём код?
import type { Locator, Page } from '@playwright/test'; // Drag an element by a given amount of pixels export const dragElementBy = async ( element: Locator, page: Page, dragByX = 0, dragByY = 0 ) => { const boundingBox = await element.boundingBox(); if (!boundingBox) { throw new Error('Element not visible'); } const startX = boundingBox.x + boundingBox.width / 2; const startY = boundingBox.y + boundingBox.height / 2; const endX = startX + dragByX; const endY = startY + dragByY; await page.mouse.move(startX, startY); await page.mouse.down(); await page.mouse.move(endX, endY); await page.mouse.up(); }; // Simulate swipe gesture for going back export const ionSwipeToGoBack = async (page: Page, shouldGoBack = false) => { const viewport = page.viewportSize(); if (!viewport) return; const startX = 50; const endX = shouldGoBack ? viewport.width - 50 : 50; const y = viewport.height / 2; await page.mouse.move(startX, y); await page.mouse.down(); await page.mouse.move(endX, y); await page.mouse.up(); }