You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

BackstopJS点击输入框触发选择器等待超时错误该如何解决?

问题原因
  • 你在clickSelector中使用了大量Angular框架生成的动态交互类:ng-not-empty、ng-dirty、ng-touched这类类名,都是用户点击输入框、输入内容之后才会被动态添加到元素上的。页面刚加载完成时,输入框实际携带的类是ng-pristine、ng-untouched、ng-empty,和你写的选择器完全不匹配,导致BackstopJS一直找不到目标元素,触发超时错误。
  • 冗余的类名选择完全没有必要:元素已经设置了唯一iduserName,仅靠id即可实现精准定位,不需要叠加其他类名增加选择器的匹配限制。
解决方案

直接将clickSelector的值简化为#userName即可,修改后的配置如下:

"scenarios": [
    {
      "label": "testLogin",
      "url": "https://test.com/myTest/#/login",
      "referenceUrl": "https://stage.test.com/myTest/#/login",
      "clickSelector": "#userName",
      "delay": 5000
    }
]

如果确实需要叠加类名做更严格的匹配,只保留加载完成后就存在的静态类即可,比如#userName.form-control。


内容的提问来源于stack exchange,提问作者user3624378

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 11:54:04