我有这个设置,我可以使用带有摩卡风格的Nightwatch
tests.js:
var nightwatch = require('nightwatch');
var config = require('./nightwatch.json');
describe('Github', function () {
//var client = nightwatch.initClient(config.test_settings.default);
var client = nightwatch.initClient(config);
var browser = client.api();
this.timeout(99999999);
before(function () {
browser.perform(function () {
console.log('beforeAll')
});
});
beforeEach(function (done) {
browser.perform(function () {
console.log('beforeEach')
});
client.start(done);
});
it('Demo test GitHub', function (done) {
browser
.url('https://github.com/nightwatchjs/nightwatch')
.waitForElementVisible('body', 5000)
.assert.title('GitHub - nightwatchjs/nightwatch: Automated testing and continous integration framework based on node.js and selenium webdriver');
client.start(done);
});
});
我执行如下
$> ./node_modules/.bin/mocha ./tests.js
只要我自己启动selenium-standalone,这就有效。但是,如果我想在Browserstack上运行我的测试怎么办?在我的nightwatch.json里面,我可以定义“selenium”设置
{
"src_folders": ["tests"],
"selenium": {
"start_process": false,
"host": "hub-cloud.browserstack.com",
"port": 80
},
"test_settings": {
"default": {
"desiredCapabilities": {
"browserstack.user": "my-username",
"browserstack.key": "my-access-key",
"browserstack.debug": true,
"browser": "IE",
"resolution": "1024x768",
"project": "nightwatch",
"build": "mocha"
}
}
}
}
但这似乎被忽略了。所以问题是,考虑到上述情况,我该如何连接到远程selenium服务器?