diff --git a/.changeset/tender-teeth-fail.md b/.changeset/tender-teeth-fail.md new file mode 100644 index 00000000..8f25abdc --- /dev/null +++ b/.changeset/tender-teeth-fail.md @@ -0,0 +1,5 @@ +--- +"webdriver-image-comparison": patch +--- + +Fix an issue in Web where the takeElementScreenshot does not consider the DPR of the device diff --git a/packages/webdriver-image-comparison/src/commands/saveWebElement.ts b/packages/webdriver-image-comparison/src/commands/saveWebElement.ts index e0e49f10..e30e5696 100644 --- a/packages/webdriver-image-comparison/src/commands/saveWebElement.ts +++ b/packages/webdriver-image-comparison/src/commands/saveWebElement.ts @@ -90,7 +90,8 @@ export default async function saveWebElement( isIOS, isLandscape, // When the element needs to be resized, we need to take a screenshot of the whole page - fallback: !!saveElementOptions.method.resizeDimensions || false, + // or when devicePixelRatio is different than 1 as the browser takeElementScreenshot does not consider DPR + fallback: (devicePixelRatio && devicePixelRatio > 1) || !!saveElementOptions.method.resizeDimensions || false, screenShot, takeElementScreenshot, })