我做終端使用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