我看到其他与量角器相关的帖子,提到了如何等待某个元素变得可见。但是,最近,我遇到了相反的用例。我想等待一个元素,直到它变得不可见。因为我找不到关于它的任何具体信息。我继续并提出了解决方案。
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.
谢谢
推荐答案使用elementexplorer(github/angular/protractor/blob/master/docs/debugging.md )我看了一下量角器对象,找到了一个对我来说效果很好的答案:
Using the elementexplorer (github/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));更多推荐
量角器:等待元素变得不可见/隐藏
发布评论