运行 WebdriverIO 'spec' 作为节点文件进行测试
Running WebdriverIO 'spec' tests as node file
我是 webdriverio 的新手。我不明白应该如何在节点应用程序中配置和使用它。
您如何 运行 'spec' 在导入 webdriverio 时进行测试?可以吗?
// based on http://webdriver.io/guide.html
var webdriverio = require('webdriverio');
var options = {
desiredCapabilities: {
browserName: 'firefox'
},
specs: './test/spec/**' // why doesn't this work, when it would work when run from the wdio cli
};
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.title(function(err, res) {
console.log('Title was: ' + res.value);
})
.end();
WebdriverIO 有两种使用方式。独立模式允许您在任意 NodeJS 脚本中使用 WebdriverIO API 集成测试自动化(例如 this example). It is often used to embed WebdriverIO into a different library like Chimp.js.
另一种方法是 WDIO 测试运行器(cli 运行器),它更适合进行充分的端到端测试。它需要一个配置文件(wdio.conf.js 或您想要的任何名称)并将此文件名作为参数传递给 wdio cli 命令(例如 these examples)。如果你想为你的项目创建一个 e2e 测试套件,这是常用的方法。
我是 webdriverio 的新手。我不明白应该如何在节点应用程序中配置和使用它。 您如何 运行 'spec' 在导入 webdriverio 时进行测试?可以吗?
// based on http://webdriver.io/guide.html
var webdriverio = require('webdriverio');
var options = {
desiredCapabilities: {
browserName: 'firefox'
},
specs: './test/spec/**' // why doesn't this work, when it would work when run from the wdio cli
};
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.title(function(err, res) {
console.log('Title was: ' + res.value);
})
.end();
WebdriverIO 有两种使用方式。独立模式允许您在任意 NodeJS 脚本中使用 WebdriverIO API 集成测试自动化(例如 this example). It is often used to embed WebdriverIO into a different library like Chimp.js.
另一种方法是 WDIO 测试运行器(cli 运行器),它更适合进行充分的端到端测试。它需要一个配置文件(wdio.conf.js 或您想要的任何名称)并将此文件名作为参数传递给 wdio cli 命令(例如 these examples)。如果你想为你的项目创建一个 e2e 测试套件,这是常用的方法。