使用 each() 方法时的量角器过时元素引用

Protractor stale element reference when using the each() method(使用 each() 方法时的量角器过时元素引用)
本文介绍了使用 each() 方法时的量角器过时元素引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于在量角器中使用 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() 方法时的量角器过时元素引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)