Skip to content

Commit

Permalink
Merge 434720f into 9710fbc
Browse files Browse the repository at this point in the history
  • Loading branch information
zivyangll committed Jul 16, 2020
2 parents 9710fbc + 434720f commit 824fbf9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ const extendsMixIn = wd => {
* @type utility
* @returns {Promise.<boolean>}
*/
wd.addPromiseChainMethod('saveScreenshots', function(context) {
wd.addPromiseChainMethod('saveScreenshots', function(context, params) {
const reporterDir = process.env.MACACA_REPORTER_DIR || cwd;
const reportspath = path.join(reporterDir, 'reports');
const filepath = path.join(reportspath, 'screenshots', `${uuid()}.png`);
mkdir(path.dirname(filepath));

return this.saveScreenshot(filepath).then(() => {
return this.saveScreenshot(filepath, params).then(() => {
appendToContext(context, `${path.relative(reportspath, filepath)}`);
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/web/react-router-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ exports.getRouter = (data, options = {}) => {
isMatched = matchPath(pathname, currentRoute) || isMatched;
}
}, {
extname: '.js',
extname: '.js'
});
});
currentRoute.path = currentRoute._path || currentRoute.path;
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": "3.3.1",
"version": "3.3.2",
"description": "Macaca wd client",
"keywords": [
"macaca",
Expand Down
6 changes: 4 additions & 2 deletions wd/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -1102,9 +1102,10 @@ commands.waitForVisible = function(using, value, timeout, pollFreq) {
*/
commands.takeScreenshot = function() {
var cb = findCallback(arguments);
var params = arguments[0];
this._jsonWireCall({
method: 'GET'
, relPath: '/screenshot'
, relPath: `/screenshot${url.format({query: params})}`
, cb: callbackWithData(cb, this)
});
};
Expand All @@ -1120,6 +1121,7 @@ commands.saveScreenshot = function() {
var cb = findCallback(arguments);
var fargs = utils.varargs(arguments);
var _path = fargs.all[0];
var _params = fargs.all[1];
var dir = process.env.CUSTOM_DIR || '';

function buildFilePath(_path, cb) {
Expand All @@ -1141,7 +1143,7 @@ commands.saveScreenshot = function() {
}

buildFilePath(_path, function(err, filePath) {
commands.takeScreenshot.apply(_this, [function(err, base64Data) {
commands.takeScreenshot.apply(_this, [_params, function(err, base64Data) {
if(err) { return cb(err); }
require("fs").writeFile(filePath, base64Data, 'base64', function(err) {
if(err) { return cb(err); }
Expand Down

0 comments on commit 824fbf9

Please sign in to comment.