【发布时间】:2015-09-06 02:33:37
【问题描述】:
我正在测试一个使用 angular.js 构建的 SPA,并且我正在使用页面对象模式来编写我的测试。在应用程序中,我们有许多将被更新的列表。例如,有一个附件列表,在添加/删除附件时会更新。要添加附件,我们有一个模式窗口,当我们上传文件并单击确定时。文件上传和列表更新。
我写了 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');
});
});
});
查看MeetingTabPage
this.getMeetingAttchments = function () {
return element.all(by.repeater('attachment in meeting.AttachmentViewModelList track by $index'));
};
this.getMeetingAttachmentCount = function () {
return this.getMeetingAttchments().count();
};
我需要在上传文件后以某种方式更新页面对象。我该怎么做。
【问题讨论】:
标签: angularjs selenium jasmine protractor angularjs-e2e