【发布时间】:2016-08-08 16:25:43
【问题描述】:
下面的 mocha 和 webdriverio 脚本在页面加载之前传递断言。
当元素本身可能还不存在时,我不明白它是如何传递所有内容的。页面加载后,我可以看到该元素没有被点击。是假通行证吗?如何在代码中解决这个问题?
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().then(function(title){
title.should.equal('Platform Configurator');
});
done();
});
it('should assert sub heading', function(done) {
browser.getText('h3').then(function(text) {
text.should.equal('API');
console.log(text);
});
done();
});
it('should click on selenium', function(done) {
browser.click('#main-content > div > ng-view > div > div:nth-child(1) > div.choice-buttons.choice-api > div:nth-child(2)')
done();
});
});
【问题讨论】:
标签: javascript node.js mocha.js chai webdriver-io