我在进行端到端测试时使用了Protractor软件。一些元素被设置为ng-show。
请问有人能告诉我如何使用Protractor检查这些元素是否可见吗?
我在进行端到端测试时使用了Protractor软件。一些元素被设置为ng-show。
请问有人能告诉我如何使用Protractor检查这些元素是否可见吗?
expect($('#foo').isDisplayed()).toBe(true); // or false to test that it's hidden
或者expect(element(by.id('foo')).isDisplayed()).toBe(true);
我发现isDisplayed()返回一个promise,在.then中你会得到一个布尔值。所以代码看起来更像这样:
$('#foo').isDisplayed().then(function(isDisplaying) {
expect(isDisplaying).toBe(true);
});
then()
。 - finspin.then
返回的布尔值。 - Matt Gooassert
。var elements = element.all(by.id('foo'))
.filter(function(el){
return el.isDisplayed();
});
expect(elements.count()).toEqual(2);
expect($('#foo').isDisplayed()).toBe(true);