Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor : wait for element to become invisible/hidden

Tags:

I saw other protractor related post mentioning about how to wait for an element to become visible. However, recently, I ran into an opposite use case. I wanted to wait for an element until it becomes invisible. Since I could not find anything specific about it. I went ahead and came up with a solution.

var ptor = protractor.getInstance();     ptor.wait(function() {          return element(by.css('#my-css-here')).isDisplayed().then(function(isVisible){             console.log('is visible :' + isVisible);             return !isVisible;         });      }, 12000).then(function(){         //do whatever you want  }); 

hopefully it helps. any suggestion is welcome.

Thanks,

like image 983
vichsu Avatar asked Oct 16 '14 18:10

vichsu


1 Answers

Using the elementexplorer (https://github.com/angular/protractor/blob/master/docs/debugging.md) I looked at the protractor object and found an answer that is working wonderfully for me:

var el = element(by.id('visibleElementId')); browser.driver.wait(protractor.until.elementIsNotVisible(el)); 
like image 121
Al Joslin Avatar answered Oct 20 '22 12:10

Al Joslin