量角器顯示錯誤信息 沒有列表項目。量角器 - 錯誤信息:預期0到等於5
conFusion App E2E Testing menu 0 item should show the number of comments Message: Expected 0 to equal 5. Stack: Error: Failed expectation at Object. (/Users/fullStock/anglerJs/conFusion/test/e2e/scenarios.js:37:23)
我做端到端測試,以確保將出現頁面上的評論列表的數量是5。我使用JSON服務器提供了數據。我認爲問題是元素還沒有出現在DOM中。是否有任何方法可以告訴量角器等待一個元素最終出現在DOM中?
代碼端對端測試
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);
});
代碼的HTML註釋
<h4> Customer Comments
<span style="font-size:15px;">sorted by:<input type="text" ng-model="FiltText"></span></h4>
<blockquote ng-repeat="commet in dish.comments |orderBy:FiltText">
<h5>{{commet.rating}} Stars</h5>
<h5>{{commet.comment}}</h5>
<footer>{{commet.author}}, <span>{{commet.date|date}}.</span></footer>
</blockquote>
量角器配置
exports.config = {
allScriptsTimeout: 11000,
specs: [
'e2e/*.js'
],
capabilities: {
browserName: 'chrome'
},
baseUrl: 'http://localhost:3001/',
framework: 'jasmine',
directConnect: true,
jasmineNodeOpts: {
defaultTimeoutInterval:30000
}
};
您是否有機會手動檢查此問題? 還有一件事是你的定位器似乎有所改善。讓我用這個特定的定位器回答這個問題。請檢查並讓我知道 – krishnarajanr
是的。我手動檢查。實際上,我輸入終端gulp手錶來提供這個web應用程序的列表是存在的。每件事情都是正確的,但是當我使量角器做測試時,測試失敗。 – munirah