【问题标题】:How to run testcafe via node如何通过节点运行 testcafe
【发布时间】:2018-09-25 15:14:18
【问题描述】:

我在使用 testcafe 进行测试时使用了这两个命令

set SELENIUM_SERVER=http://xxx:4447/wd/hub
testcafe selenium:"internet explorer" Test.js

如何重写它以通过节点和测试运行器运行它? IE。我想写这样的东西:

set SELENIUM_SERVER=http://xxx:4447/wd/hub
node tRunner.js selenium:"internet explorer"

在使用节点时无法弄清楚正确的顺序是什么。

【问题讨论】:

    标签: node.js testing automated-tests e2e-testing testcafe


    【解决方案1】:

    您可以创建一个 TestCafe nodejs 应用程序并使用 TestCafe 的 API 来执行您的测试。

    例如,您的应用程序可能如下所示:

    const createTestCafe = require('testcafe');
    let testcafe         = null;
    
    createTestCafe('localhost', 1337, 1338)
        .then(tc => {
            testcafe     = tc;
            const runner = testcafe.createRunner();
    
            return runner
                .src('Test.js')
                .browsers('selenium:"internet explorer"')
                .run();
        })
        .then(failedCount => {
            console.log('Tests failed: ' + failedCount);
            testcafe.close();
        });
    

    在其文档中了解有关 TestCafe API 的更多信息:Programming Interface

    【讨论】:

    • 我建议您查看以下主题,您可以在其中了解如何在headless mode 中进行测试。简而言之,如果你使用浏览器的路径,你的论点应该由三部分组成。
    猜你喜欢
    • 1970-01-01
    • 2018-01-09
    • 2015-06-09
    • 2014-05-21
    • 2019-08-17
    • 1970-01-01
    • 2020-06-24
    • 2018-08-10
    • 1970-01-01
    相关资源
    最近更新 更多