From ac600232dba53136d87289542fa6d0189be1d09f Mon Sep 17 00:00:00 2001 From: yihuineng <471110230@qq.com> Date: Thu, 12 Oct 2023 18:39:07 +0800 Subject: [PATCH] fix: viewport --- lib/helper/element.js | 14 +++++++++----- package.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/helper/element.js b/lib/helper/element.js index 79b73d5..8859e5a 100644 --- a/lib/helper/element.js +++ b/lib/helper/element.js @@ -11,7 +11,7 @@ const domEventLibSource = fs.readFileSync(domEventLib, 'utf8'); const cwd = process.cwd(); const reporterDir = process.env.MACACA_REPORTER_DIR || cwd; -const reportspath = path.join(reporterDir, 'reports'); +const reportsPath = path.join(reporterDir, 'reports'); const safeQuote = string => JSON.stringify(String(string)); @@ -29,8 +29,12 @@ module.exports = wd => { platformName: 'playwright', browserName: 'chromium', deviceScaleFactor: 2, + viewport: { + width: options.width, + height: options.height, + }, ...options, - }).setWindowSize(options.width, options.height); + }); }); /** @@ -77,11 +81,11 @@ module.exports = wd => { * @return {Promise.} */ wd.addPromiseChainMethod('saveScreenshots', function(context, params) { - const filepath = path.join(reportspath, 'screenshots', `${uuid()}.png`); + const filepath = path.join(reportsPath, 'screenshots', `${uuid()}.png`); mkdir(path.dirname(filepath)); return this.saveScreenshot(filepath, params).then(() => { - appendToContext(context, `${path.relative(reportspath, filepath)}`); + appendToContext(context, `${path.relative(reportsPath, filepath)}`); }); }); @@ -95,7 +99,7 @@ module.exports = wd => { wd.addPromiseChainMethod('saveVideos', function(context, params = {}) { params.video = true; return this.saveScreenshot(null, params).then(filepath => { - appendToContext(context, `${path.relative(reportspath, filepath)}`); + appendToContext(context, `${path.relative(reportsPath, filepath)}`); }); }); diff --git a/package.json b/package.json index 17b974f..0b1b2b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "macaca-wd", - "version": "4.3.1", + "version": "4.3.2", "description": "Macaca webdirver API for Node.js", "keywords": [ "macaca",