UNPKG

e2ed

Version:

E2E testing framework over Playwright

22 lines (21 loc) 840 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getVerticalDistanceBetweenSelectors = void 0; /** * Returns vertical distance between selectors in pixels. * TODO: support Smart Assertions. */ const getVerticalDistanceBetweenSelectors = async (selectorA, selectorB) => { const boundingClientRectOfSelectorA = await selectorA.boundingClientRect; const boundingClientRectOfSelectorB = await selectorB.boundingClientRect; const { top: aTop, bottom: aBottom } = boundingClientRectOfSelectorA; const { top: bTop, bottom: bBottom } = boundingClientRectOfSelectorB; if (aTop > bBottom) { return aTop - bBottom; } if (bTop > aBottom) { return bTop - aBottom; } return 0; }; exports.getVerticalDistanceBetweenSelectors = getVerticalDistanceBetweenSelectors;