問題描述
由于在量角器中使用 each() 方法,我收到以下錯誤.過去它運行良好,但現在一直因此錯誤而失敗.
I am getting the error below as a result of using the each() method in protractor. It has worked fine in the past but is now consistently failing with this error.
失敗:過時的元素引用:元素未附加到頁面文檔
Failed: stale element reference: element is not attached to the page document
element.all(bars).each((element) => element.getCssValue('width'))
是否有替代方案或原因?
Is there an alternative or a reason why this might be?
(為了清楚起見,我要做的就是獲取一組稱為條形圖的 web 元素中每個元素的寬度.)
(For clarity, all I want to do is to get the width of each element in a set of web elements called bars.)
謝謝!
推薦答案
感謝所有幫助過的人.如果導致錯誤,解決方案將重試.由于元素的實時性,元素引用在獲得 css 寬度之前就發生了變化.
Thanks to everyone who helped. The solution was retry again if it resulted in error. Due to the realtime nature of the element, the element reference was changing before it had got the css width.
這篇關于使用 each() 方法時的量角器過時元素引用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!