目前,我不明白为什么终端说我的测试正在通过。我的测试设置失败了。
这是终端消息:
Google
✓ Load google search page
1 passing (22ms)
这是我用Node JS编写的测试
const assert = require('assert');
const {Builder, By, Key, until} = require('selenium-webdriver');
const suite = require('selenium-webdriver/testing')
var driver = new Builder()
.forBrowser('chrome')
.build();
describe('Google', function() {
it('Load google search page', function() {
driver.get('https://www.foobar.com')
.then(_ => driver.wait(until.titleIs('Darkness!'), 10000))
.then(_ => driver.quit());
});
});
答案 0 :(得分:3)
在想要进行异步测试时查看documentation,请使用以下格式:
it('should be fulfilled', function (done) {
promise.should.be.fulfilled.and.notify(done);
});
it('should be rejected', function (done) {
otherPromise.should.be.rejected.and.notify(done);
});
适用于您的案件:
describe('Google', function() {
it('Load google search page', function(done) {
driver.get('https://www.foobar.com')
.then(() => driver.wait(until.titleIs('Darkness!'), 10000))
.then(() => driver.quit())
.then(() => done())
.catch(done);
});
});