量角器说复选框不可见,但它是。如何调查和修复它?
Protractor says that a checkbox is not visible, but it is. How to investigate and fix it?
所以,我在 angular 应用程序中有这个 HTML:
<div class="panel">
<input class="eula" id="eula" type="checkbox" />
<label for="eula">I agree</label>
</div>
并且这两个期望在同一规格上(只是为了确保没有其他东西运行):
expect(element(by.css('.panel')).isDisplayed()).toBeTruthy();
expect(element(by.css('.eula')).isDisplayed()).toBeTruthy();
第一个,是真的。第二个是假的。真奇怪。应该也是吧。
所以,我尝试:
element( by.css( '.panel' ) ).getOuterHtml()
.then( function ( html ) {
console.log( html );
});
我得到:
<input class="eula" id="eula" type="checkbox">
据我所知,没有任何东西隐藏复选框,所以我不明白为什么量角器说它不可见。还有另一种方法可以测试这个吗?关于如何继续调试和修复它的任何想法?
来自量角器 isDisplayed() 文档:
An expectation for checking that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0.
输入显示:none 属性,这就是问题所在。
所以,我在 angular 应用程序中有这个 HTML:
<div class="panel">
<input class="eula" id="eula" type="checkbox" />
<label for="eula">I agree</label>
</div>
并且这两个期望在同一规格上(只是为了确保没有其他东西运行):
expect(element(by.css('.panel')).isDisplayed()).toBeTruthy();
expect(element(by.css('.eula')).isDisplayed()).toBeTruthy();
第一个,是真的。第二个是假的。真奇怪。应该也是吧。
所以,我尝试:
element( by.css( '.panel' ) ).getOuterHtml()
.then( function ( html ) {
console.log( html );
});
我得到:
<input class="eula" id="eula" type="checkbox">
据我所知,没有任何东西隐藏复选框,所以我不明白为什么量角器说它不可见。还有另一种方法可以测试这个吗?关于如何继续调试和修复它的任何想法?
来自量角器 isDisplayed() 文档:
An expectation for checking that an element is present on the DOM of a page and visible. Visibility means that the element is not only displayed but also has a height and width that is greater than 0.
输入显示:none 属性,这就是问题所在。