Skip to content

Commit

Permalink
feat: update media recorders api (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng committed Dec 12, 2021
1 parent 94fe934 commit 06d6cfb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lib/helper.js
Expand Up @@ -464,7 +464,7 @@ const extendsMixIn = wd => {
* @function waitForVideosSave
*/
wd.addPromiseChainMethod('waitForVideosSave', function() {
return this.execute('return window._mediaRecorders.length;')
return this.execute('return window._mediaRecorder._getMediaRecoders().length;')
.then((res) => {
const videoCounts = parseInt(res, 10);
console.log('video counts: %d', videoCounts);
Expand All @@ -474,7 +474,7 @@ const extendsMixIn = wd => {
return new Promise(resolve => {
const handle = () => {
setTimeout(() => {
this.execute('return window._mediaRecorders.length;')
this.execute('return window._mediaRecorder._getMediaRecoders().length;')
.then(res => {
const videoCounts = parseInt(res, 10);
console.log('video counts: %d', videoCounts);
Expand All @@ -496,11 +496,11 @@ const extendsMixIn = wd => {
const filepath = path.join(reportspath, 'videos', `${uuid()}.webm`);
mkdir(path.dirname(filepath));
appendToContext(context, `${path.relative(reportspath, filepath)}`);
return this.execute(`window._startMediaRecorder('${filepath}');`);
return this.execute(`window._mediaRecorder._startMediaRecorder('${filepath}');`);
});

wd.addPromiseChainMethod('stopMediaRecorder', function() {
return this.execute('window._stopMediaRecorder();');
return this.execute('window._mediaRecorder._stopMediaRecorder();');
});
};

Expand Down
18 changes: 8 additions & 10 deletions lib/macaca-wd.js
Expand Up @@ -80,26 +80,24 @@ function saveScreenshot(filepath) {}

/**
* Record a video for the use case execution process, start to create a new record.
* @summary Support: Android iOS Web(WebView)
* @returns {Promise.<string>} The screenshot as a base64 encoded PNG.
* @summary Support: Web
* @returns {Promise.<string>}
*/
function startMediaRecorder() {}

/**
* Record a video for the use case execution process, stop the record in process.
* @summary Support: Android iOS Web(WebView)
* @param {str} filepath The path to save the screenshot or left blank (will create a file in the system temp dir).
* @returns {Promise.<string>} The filepath of the screenshot.
* @summary Support: Web
* @returns {Promise.<string>}
*/
function stopMediaRecorder(filepath) {}
function stopMediaRecorder() {}

/**
* Record a video for the use case execution process, wait for the genaration of the videos in process.
* @summary Support: Android iOS Web(WebView)
* @param {str} filepath The path to save the screenshot or left blank (will create a file in the system temp dir).
* @returns {Promise.<string>} The filepath of the screenshot.
* @summary Support: Web
* @returns {Promise.<string>}
*/
function waitForVideosSave(filepath) {}
function waitForVideosSave() {}

/**
* Get the current page source.
Expand Down
5 changes: 3 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "macaca-wd",
"version": "3.3.7",
"version": "3.4.2",
"description": "Macaca wd client",
"keywords": [
"macaca",
Expand All @@ -9,7 +9,8 @@
],
"files": [
"lib/**/*.js",
"wd/**/*.js"
"wd/**/*.js",
"wd/package.json"
],
"main": "./lib/macaca-wd.js",
"repository": {
Expand Down

0 comments on commit 06d6cfb

Please sign in to comment.