我希望在运行nightwatchjs测试时使用execute填充应用程序中的字段
我尝试了以下方法:
.execute("document.getElementByClassName('.price').setAttribute('value', '19.99')")
这不起作用,没有填充字段,但是我没有收到错误。有人可以解释我可能做错了吗?
谢谢!
ps-我知道我可以使用.setValue('。price','9
.99'),但我想学习如何通过执行来做到这一点。
最佳答案
您可以尝试以下代码。只有很小的变化。
.execute("document.getElementsByClassName('price')[0].setAttribute('value', '19.99')")