当我运行一套冒烟测试时,我遇到了一个问题,即模拟测试不会发生这个问题。
代码:
it('should save widget', function () {
explorerObjectInstance.on.metricsSelector
.when
.searchMetricOnTab('application', 0);
explorerObjectInstance.on.metricsSelector
.when
.selectMetric(0);
explorerObjectInstance.on.filtersPanel.given
.selectAggregation(0);
explorerObjectInstance.on.widget.given
.changeTitle('Widget');
explorerObjectInstance.on.topToolbox.given
.saveButtonClick();
saveWidgetObjectInstance.given
.saveButtonPopupClick();
//Error here
notificationObjectInstance.then
.itShouldHaveSuccess('Widget Created Successfully');
explorerObjectInstance.then
.itShouldBeVisibleSaveAsBtt();
});
POM:
itShouldHaveSuccess: function (expectedMessage) {
expect(successNotification().isPresent()).toBeTruthy();
expect(context().getText()).toEqual(expectedMessage);
return this;
}
选择器:
function context () {
return element(by.tagName('notifications'));
}
function successNotification () {
return element(by.css('.alert-success'));
}
问题: 问题是量角器无法验证消息,尽管元素存在于DOM上。
有任何解决此问题的建议吗?
此致
答案 0 :(得分:0)
我认为问题在于你的context()选择器。实际上是否有一个带有tagName'通知的组件'?如果您尝试基于类或ID进行定位,则正确的选择器将是:
function context() {
return element(by.css('.notifications'));
}
或
function context() {
return element(by.css('#notifications'));
}