我正在测试使用页面对象模式编写测试的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();
};
我需要什么已经是莫名其妙地更新页面我上传文件后的对象。我怎样才能做到这一点。