【发布时间】:2017-02-01 12:43:22
【问题描述】:
我在网络上找到的几乎每一个示例都没有很好地解释应该如何实现 mocha 并将其与 nightwatchJS 一起使用。
无论我做什么,我都无法避免该错误消息,即使我遵循official nightwatch how-to use mocha 的所有步骤 我唯一能做的就是至少打开 google chrome 浏览器,仅此而已。
这是我要运行的代码
var nightwatch = require('nightwatch');
describe('Google', function() {
var client = nightwatch.initClient({
// Pass here options from nightwatch.json
// selenium logs; change it to true if you want to see them in console
silent : false,
desiredCapabilities: {
browserName: "chrome",
javascriptEnabled: true,
acceptSslCerts: true
}
});
var browser = client.api();
// Mocha timeout
this.timeout(15000);
it('Demo test Google', function (done) {
browser
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.setValue('input[type=text]', 'nightwatch')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#main', 'Night Watch')
.end();
client.start(done);
});
});
这是浏览器弹出后总是出现在我身上的错误信息:
INFO Request: POST /wd/hub/session
- data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY"}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":113}
1) Demo test Google
0 passing (15s)
1 failing
1) Google Demo test Google:
Error: timeout of 15000ms exceeded. Ensure the done() callback is being called in this test.
【问题讨论】:
标签: automated-tests mocha.js ui-automation nightwatch.js