如何获取 bootstrap 警告消息的文本以使用量角器进行测试
how to get the text of bootstrap alert message for testing with protractor
这是我的规格
it('should save edited majorObject', function () {
var description = element(by.id('objectDescription'));
description.clear();
description.sendKeys('edited');
var add = element(by.id('saveObject'));
add.click().then(function () {
expect(element(by.css('.alert-success')).isDisplayed()).toBe(true);
expect(element(by.css('.alert-success')).toText()).toBe("Saved Successfully");
})
});
我用过
expect(element(by.css('.alert-success')).toText()).toBe("Saved Successfully");
但它显示未定义,他们有任何替代方法吗?
您打算使用 getText()
而不是 toText()
:
expect(element(by.css('.alert-success')).getText()).toBe("Saved Successfully");
这是我的规格
it('should save edited majorObject', function () {
var description = element(by.id('objectDescription'));
description.clear();
description.sendKeys('edited');
var add = element(by.id('saveObject'));
add.click().then(function () {
expect(element(by.css('.alert-success')).isDisplayed()).toBe(true);
expect(element(by.css('.alert-success')).toText()).toBe("Saved Successfully");
})
});
我用过
expect(element(by.css('.alert-success')).toText()).toBe("Saved Successfully");
但它显示未定义,他们有任何替代方法吗?
您打算使用 getText()
而不是 toText()
:
expect(element(by.css('.alert-success')).getText()).toBe("Saved Successfully");