Alexandros Spyropoulos
Alexandros Spyropoulos

Reputation: 974

Protractor can't find element that has beeen found 2 tests before

First timer with protractor. But i got into trouble. Tried to test if an element exists, then if another element is hidden, then again if the first element is clickable and boooooom...

Protractor hangs responding with ElementNotVisibleError: Element is not currently visible and so may not be interacted with while the element have been found two tests before. Probably I'm doing something wrong, but what?

              describe( 'filters' , function () {                   

                    it ( 'has a .filter-editorial-rating .header' , function ( done ) {
                        element.all( by.css( '.filter-editorial-rating .header' ) )
                            .then( function ( el ) {
                                expect( el.length > 0).toEqual( true );
                                done();
                            });
                    });


                    it( 'ER filter is collapsed by default' , function ( done ) {

                        element.all( by.css ( '.filter-editorial-rating .content.ng-hide' ) )
                            .then( function (el) {
                                expect( el.length > 0).toEqual( true );
                                done();
                            });
                    });

                    it( 'ER filters header is clickable' , function ( done ) {
                        element( by.css( '.filter-editorial-rating .header' ) )
                                .click()   //  <--- hangs with error ElementNotVisibleError: Element is not currently visible and so may not be interacted with
                                .then( function ( el ) {
                                    done();
                                });
                    });
                });

also tried to wrap it in element.all as I did in first place (trying voodoo) but as it thanks god it didn't work. :)

Also I tried to getOuterHtml and I found that the element really exists

this...

it( 'ER filters header is clickable' , function ( done ) {
    element( by.css( '.filter-editorial-rating .header' ) )
      .getOuterHtml()
      .then( function ( html ) {
        console.log( html );
        done();
      });
});

return's this...

 <div class="header" ng-click="collapse.er = !collapse.er">
      <span class="icon icon_plus" ng-show="collapse.er"></span>
      <span class="icon icon_minus ng-hide" ng-show="!collapse.er"></span>

      <h4 class="title"> Star Rating </h4>
 </div>

Upvotes: 1

Views: 2231

Answers (1)

Alexandros Spyropoulos
Alexandros Spyropoulos

Reputation: 974

OOOOk... my bad

setting in config.js in the onPrepare() methofd the window size fixed the problem. there was a media query doing tricks with the container of that element.

var width = 1024;
var height = 600;
browser.driver.manage().window().setSize(width, height);

Upvotes: 3

Related Questions