【发布时间】:2016-11-07 09:58:34
【问题描述】:
我尝试使用不同堆栈的编译:
Mocha – 测试运行器
Chai – 断言库
webdriverio – 浏览器控件绑定
Selenium - 浏览器抽象和运行工厂
PhantomJS - 快速无头浏览器
所以我启动了一个像这样的 selenium 服务器
java -jar selenium-server.jar
然后我像这样启动我的测试
mocha test.js -t 10000
这是我的 test.js
var webdriverio = require('webdriverio');
var options = { desiredCapabilities: { browserName: 'phantomjs' } };
var client = webdriverio.remote(options);
describe('Test example.com', function(){
before(function(done) {
client.init().url('/* my website */');
done();
//client.pause(5000);
var chai = require('chai');
global.expect = chai.expect;
chai.Should();
});
describe('Check homepage', function(){
it('should wait 3 secondes', function() {
client.pause(3000);
});
it('should see the correct title', function() {
client.waitForValue('#logoHeaderNav', 3000);
client.url('/* my website */');
client.getTitle().should.be.equal('/*my title*/');
});
});
after(function(done) {
client.end();
done();
});
});
我得到的结果是:
# mocha test.js -t 10000
Test example.com
Check homepage
✓ should wait 3 secondes
1) should see the correct title
1 passing (108ms)
1 failing
1) Test example.com Check homepage should see the correct title:
AssertionError: expected { state: 'pending' } to equal '/*my title */'
at Context.<anonymous> (test.js:90:35)
有什么想法我做错了吗??
【问题讨论】:
-
在你的 wdio 配置文件中,你有 'sync: true,' 吗?
-
这个问题解决了吗?
标签: javascript selenium mocha.js chai webdriver-io