我正在測試使用頁面對象模式編寫測試的angular.js和im構建的SPA。在應用程序中,我們有許多將被更新的列表。例如,有附件列表會在附件添加/刪除時更新。要添加附件,我們有一個模式窗口,當我們上傳文件並點擊確定。文件上傳和列表更新。當DOM元素髮生變化時,量角器 - 頁面對象未更新
我寫了2個頁面對象,一個用於上傳模式窗口,另一個用於預覽附件列表。在我的測試中,我首先得到附件的當前計數,然後我點擊一個按鈕來激活模態窗口並附加文件。然後我在預覽頁面再次計算附件數量,並將其與1進行比較,但測試失敗。頁面對象不更新,它仍然顯示連接數爲2
測試
it('Should attach a file when a file is selected and OK button is pressed.', function() {
var currentFileCount = viewMeetingTabPage.getMeetingAttachmentCount();
viewMeetingPage.clickAddAttachmentButton();
addAttchmentPage.attachFile();
addAttchmentPage.clickConfimAttachFileButton();
currentFileCount.then(function (curCount) {
viewMeetingTabPage.getMeetingAttachmentCount().then(function (newCount) {
expect(newCount).toBe(curCount + 1);
//expect(viewMeetingTabPage.getMeetingAttachmentName()).toBe('test-file.pdf');
});
});
});
ViewMeetingTabPage
this.getMeetingAttchments = function() {
return element.all(by.repeater('attachment in meeting.AttachmentViewModelList track by $index'));
};
this.getMeetingAttachmentCount = function() {
return this.getMeetingAttchments().count();
};
我需要什麼已經是莫名其妙地更新頁面我上傳文件後的對象。我怎樣才能做到這一點。