我做终端使用protractor.When我启动,在我看来这个消息的测试量角器:不要等待元素出现在大教堂
混乱应用端到端测试菜单0项应该显示结束测试第一个评论作者为 消息: 失败:不使用定位器找到的元素:by.model(“FiltText”)
我怎样才能让量角器等到元素出现在DOM?
相应量角器配置代码是:由于使用量角器控制流
var EC = protractor.ExpectedConditions;
var timeout = 5000; // in miliseconds
// Waits for the element to be present on the dom.
browser.wait(EC.presenceOf(element(by.model("FiltText"))), timeout);
// Here you can safely use your element, because here it is guaranted to be present.
:
exports.config = {
allScriptsTimeout:11000,
specs: [
'e2e/*.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'http://localhost:3001/',
framework: 'jasmine',
directConnect: true,
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000
}
};
scenarios.js包含E2E测试代码
describe('menu 0 item', function() {
beforeEach(function() {
browser.get('index.html#/menu/0');
});
it('should have a name', function() {
var name = element(by.binding('dish.name'));
expect(name.getText()).
toEqual('Uthapizza Hot $4.99');
});
it('should show the number of comments as', function() {
expect(element.all(by.repeater('comment in dish.comments'))
.count()).toEqual(5);
});
it('should show the first comment author as', function() {
element(by.model('FiltText')).sendKeys('author');
expect(element.all(by.repeater('comment in dish.comments'))
.count()).toEqual(5);
var author = element.all(by.repeater('comment in dish.comments'))
.first().element(by.binding('comment.author'));
expect(author.getText()).toContain('25 Cent');
});
});
可能的复制http://stackoverflow.com/questions/30205235 /量角器等待元素为dom) –
错误中测试的名称不在您提供的规范中的任何位置。代码在哪里? – Gunderson
我添加了测试代码。 PLZ检查它。 – munirah