testing - 具有数据属性的选择器
问题描述
我在为具有 data-qa 属性的按钮创建选择器时遇到了麻烦。见html:
<div class="stepsInfo_children__4knGx"><button type="button" class="steps_stepsButton__3Ykpu" data-qa="next-design">
我尝试了这个实现,但没有成功(来自官方文档):
this.nextDesign = Selector("div").withAttribute("data-qa","next-design");
解决方案
亚历克斯是对的,你错过了它实际上是一个按钮。
或者您可以避免withAttribute()
并创建以下选择器:
this.nextDesign = Selector('[data-qa="next-design"]');
它有点短,这可能使它更具可读性。
推荐阅读
- ios - UserDefaults 在框架中使用时不保存
- gitlab - 日志超出 Gitlab 上 4194304 字节的限制
- php - 如何检查php中的两个变量是否相同?
- c# - 正确实施 IComparable
在 C# 8 中设置为启用 Nullable 的 Struct - javascript - 如何在锚标记/链接上打开模式弹出窗口在 c# 中单击以在弹出窗口中打开另一个 .aspx 页面
- python - 通过 ansible 使用 conda 命令的错误
- javascript - 激活时更改粘性文本的颜色
- amazon-web-services - 如何在不使用 AWS 容器的情况下创建服务网格?
- c# - System.IO.IOException:无效的参数,当试图在 web api 中保存 FormFile
- json - 新行不适用于 jspdf,结果被覆盖