Skip to content

Commit

Permalink
fix: viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuineng committed Oct 12, 2023
1 parent d260eb2 commit ac60023
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions lib/helper/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);
});
});

/**
Expand Down Expand Up @@ -77,11 +81,11 @@ module.exports = wd => {
* @return {Promise.<boolean>}
*/
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)}`);
});
});

Expand All @@ -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)}`);
});
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "macaca-wd",
"version": "4.3.1",
"version": "4.3.2",
"description": "Macaca webdirver API for Node.js",
"keywords": [
"macaca",
Expand Down

0 comments on commit ac60023

Please sign in to comment.