Bob Bai
Bob Bai

Reputation: 283

Is there a way for protractor to execute Windows command in test cases?

I am looking for a way to execute Windows commands in protractor test cases, like this: copy D:\xx\xx\xx.js d:\xxxx\xxxx

Is it possible to do so? Or is there any other way to do this?

Upvotes: 0

Views: 611

Answers (1)

Bob Bai
Bob Bai

Reputation: 283

Actually I need to move a file to another location. I have successfully made it by nodeJS function fs.rename() like the following:

var fs = require('fs');
var path = require('path');

var fileName = "coverflow-3.0.1.zip";

var sourceFile = path.join(__dirname, fileName);
var destPath = path.join(__dirname, fileName);

fs.rename(sourceFile, destPath, function (err) {
  if (err) throw err;
  fs.stat(destPath, function (err, stats) {
    if (err) throw err;
    console.log('stats: ' + JSON.stringify(stats));
  });
});

Upvotes: 1

Related Questions