【发布时间】:2018-11-05 12:20:10
【问题描述】:
我为我的 Web 应用程序的某些部分编写了一个测试。我需要在测试运行过程中运行批处理文件 (batch.exe)。我的测试是:
var exec = require('child_process').execFile;
describe('Sample Test', function () {
describe('When click on browse', function () {
beforeEach(function () {
browser.get('http://192.168.1.152/public/documents');
element(by.linkText('upload')).click();
element(by.css(".dropzone")).click();
browser.sleep(5000);
// <---------- **** this place need to run file
exec('file-upload.exe', function(err, data) {
console.log(err);
console.log(data.toString());
});
element(by.css("button")).click();
});
it('Should be', function () {
expect(element(by.css("span")).getText()).toBe('file uploaded');
});
});
});
我使用了child_process节点模块,但它不起作用?我该怎么办?有没有办法解决这个问题?
【问题讨论】:
-
它不起作用 - 什么不起作用?如果您依赖它的结果,这显然无法正常工作,因为
execFile是异步的。使用execFileSync或承诺。 -
请写正确的代码
-
什么代码?你没有说明问题是什么。
-
我解决了问题
标签: javascript node.js protractor e2e-testing