在量角器测试中执行批处理文件

玛莎起亚拉德

我为 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节点模块,但它不起作用?我应该怎么办?有没有办法解决这个问题?

玛莎起亚拉德

我用这段代码解决了问题:

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
             setTimeout(function () {
                execFile('file-upload.exe', function(error, stdout, stderr) {
                   if (error) {
                      throw error;
                   }
                   console.log(stdout);
                });
            },3000);

            element(by.css("button")).click();
        });

        it('Should be', function () {
            expect(element(by.css("span")).getText()).toBe('file uploaded');
        });
    });
});

由于 execFile 在beforeAll函数之前运行,并且我需要暂停它几秒钟,我将execFile函数放入其中setTimeOut以进行延迟。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章