问题描述:

So, I have this HTML inside an angular app:

<div class="panel">

<input class="eula" id="eula" type="checkbox" />

<label for="eula">I agree</label>

</div>

And this two expectations on the same spec (just to be sure that there's no other stuff running):

expect(element(by.css('.panel')).isDisplayed()).toBeTruthy();

expect(element(by.css('.eula')).isDisplayed()).toBeTruthy();

First one, is true. Second one is false. That's strange. It should be also true.

So, i try:

element( by.css( '.panel' ) ).getOuterHtml()

.then( function ( html ) {

console.log( html );

});

And i get:

<input class="eula" id="eula" type="checkbox">

From what I see, there's nothing hidding the checkbox so i don't understand why protractor says that is not visible. Is there another way to test this? Any idea on how to proceed to debug and fix it?

网友答案:

From protractor isDisplayed() documentation:

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.

The input had a display: none property, and that was the problem.

相关阅读:
Top