@wdio/image-comparison-core
Version:
Image comparison core module for @wdio/visual-service - WebdriverIO visual testing framework
20 lines (19 loc) • 852 B
JavaScript
/**
* Get the element position to the top of the screen of the device, not the top of the webview
* This method is used for Android native and iOS screenshots
*/
export function getElementPositionTopScreenNativeMobile(element, { isLandscape, safeArea, screenHeight, screenWidth, sideBarWidth, statusBarAddressBarHeight, }) {
// Get some heights and widths
const { innerHeight } = window;
// Determine element position
const elementPosition = element.getBoundingClientRect();
const y = (screenHeight === innerHeight || screenWidth === innerHeight)
? elementPosition.top
: statusBarAddressBarHeight + elementPosition.top;
return {
height: elementPosition.height,
width: elementPosition.width,
x: elementPosition.left + (isLandscape ? safeArea : 0) + sideBarWidth,
y: y,
};
}