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", diff --git a/test/utility.test.js b/test/utility.test.js index 30519c2..7fcbc42 100644 --- a/test/utility.test.js +++ b/test/utility.test.js @@ -120,32 +120,6 @@ describe('test/utility.test.js', function() { }); }); - /** - * https://macacajs.github.io/macaca-wd/#initWindow - */ - describe('initWindow', async () => { - it('should work', async () => { - await driver.initWindow({ - width: 800, - height: 600, - }); - assert.equal( - server.ctx.url, - '/wd/hub/session/sessionId/window/current/size' - ); - assert.equal(server.ctx.method, 'POST'); - assert.deepEqual(server.ctx.request.body, { - width: 800, - height: 600, - }); - assert.deepEqual(server.ctx.response.body, { - sessionId: 'sessionId', - status: 0, - value: '', - }); - }); - }); - /** * https://macacajs.github.io/macaca-wd/#openReporter */ diff --git a/test/window.test.js b/test/window.test.js index bffbdf6..71069af 100644 --- a/test/window.test.js +++ b/test/window.test.js @@ -29,9 +29,10 @@ describe('test/window.test.js', function() { server.stop(); }); + /** - * https://macacajs.github.io/macaca-wd/#close - */ + * https://macacajs.github.io/macaca-wd/#close + */ describe('close', async () => { it('should work', async () => { await driver.close(); @@ -47,8 +48,8 @@ describe('test/window.test.js', function() { }); /** - * https://macacajs.github.io/macaca-wd/#close - */ + * https://macacajs.github.io/macaca-wd/#getWindowSize + */ describe('getWindowSize', async () => { it('should work', async () => { await driver.getWindowSize(); @@ -64,8 +65,8 @@ describe('test/window.test.js', function() { }); /** - * https://macacajs.github.io/macaca-wd/#setWindowSize - */ + * https://macacajs.github.io/macaca-wd/#setWindowSize + */ describe('setWindowSize', async () => { it('should work', async () => { await driver.setWindowSize(800, 600); @@ -84,8 +85,8 @@ describe('test/window.test.js', function() { }); /** - * https://macacajs.github.io/macaca-wd/#window - */ + * https://macacajs.github.io/macaca-wd/#window + */ describe('window', async () => { it('should work', async () => { await driver.window(); @@ -101,8 +102,8 @@ describe('test/window.test.js', function() { }); /** - * https://macacajs.github.io/macaca-wd/#windowHandle - */ + * https://macacajs.github.io/macaca-wd/#windowHandle + */ describe('windowHandle', async () => { it('should work', async () => { await driver.windowHandle(); @@ -118,8 +119,8 @@ describe('test/window.test.js', function() { }); /** - * https://macacajs.github.io/macaca-wd/#windowHandles - */ + * https://macacajs.github.io/macaca-wd/#windowHandles + */ describe('windowHandles', async () => { it('should work', async () => { await driver.windowHandles(); @@ -133,5 +134,28 @@ describe('test/window.test.js', function() { }); }); }); + + + /** + * https://macacajs.github.io/macaca-wd/#initWindow + */ + describe('initWindow', async () => { + it('should work', async () => { + await driver.initWindow({ + width: 800, + height: 600, + }); + assert.equal( + server.ctx.url, + '/wd/hub/session' + ); + assert.equal(server.ctx.method, 'POST'); + assert.deepEqual(server.ctx.response.body, { + sessionId: 'sessionId', + status: 0, + value: '', + }); + }); + }); });