From 153012c0b89c09f6f2f6c9db59188dd2c981bdb2 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Fri, 17 Jan 2025 15:38:51 +0100 Subject: [PATCH] fix(appium): error when saving screenshot --- lib/helper/WebDriver.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index a53d08787..cdd0229f2 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -1800,6 +1800,13 @@ class WebDriver extends Helper { const originalWindowSize = await this.browser.getWindowSize() + // this case running on device, so we could not set the windowSize + if (this.browser.isMobile) { + this.debug(`Screenshot has been saved to ${outputFile}, size: ${originalWindowSize.width}x${originalWindowSize.height}`) + const buffer = await this.browser.saveScreenshot(outputFile) + return buffer + } + let { width, height } = await this.browser .execute(function () { return {