[英]assertion error using chai with mocha and webdriverio
我收到此錯誤
AssertionError: expected { state: 'pending' } to equal 'Platform Configurator'
我已經通過npm
安裝了chai
和mocha
它運行測試,但未通過斷言
var webdriverio = require('webdriverio');
var should = require('chai').should()
var expect = require('chai').expect()
var options = {
desiredCapabilities: {
browserName: 'chrome'
}
};
before(function() {
browser=webdriverio.remote(options)
return browser.init()
});
describe('sauce labs page test', function() {
it('should assert page title', function(done) {
browser.url('https://docs.saucelabs.com/reference/platforms-configurator/?_ga=1.5883444.608313.1428365147#/');
browser.getTitle().should.equal('Platform Configurator');
done();
});
});
編輯:
如果使用此方法,則使用setTimeout
可以在測試完成甚至頁面加載之前通過。
var webdriverio = require('webdriverio');
var should = require('chai').should()
var expect = require('chai').expect()
var options = {
desiredCapabilities: {
browserName: 'chrome'
}
};
before(function() {
browser=webdriverio.remote(options)
return browser.init()
});
describe('sauce labs page test', function() {
it('should assert page title', function() {
browser.url('https://docs.saucelabs.com/reference/platforms-configurator/?_ga=1.5883444.608313.1428365147#/');
setTimeout(function () {
browser.getTitle().should.equal('Platform Configurator');
}, 10000)
});
});
解決getTitle
browser.getTitle().then(function(title){
title.should.equal('Platform Configurator');
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.