From e0c5d45ff72c0174f7c7839fca78ac7989b7e4d1 Mon Sep 17 00:00:00 2001 From: Alexandre Pereira Date: Wed, 23 Apr 2025 01:25:56 +0100 Subject: [PATCH 1/2] fix: dpr issue with takeElementScreenshot in web --- .../webdriver-image-comparison/src/commands/saveWebElement.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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, }) From 459525fec1d9b3fb00dc37cc9b9c50536a177388 Mon Sep 17 00:00:00 2001 From: Alexandre Pereira Date: Wed, 23 Apr 2025 01:30:57 +0100 Subject: [PATCH 2/2] chore: changeset --- .changeset/tender-teeth-fail.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tender-teeth-fail.md 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