【问题标题】:CasperJs test can't found css selector (test broke after migrate from jade to pug)CasperJs 测试找不到 css 选择器(从玉迁移到哈巴狗后测试中断)
【发布时间】:2018-07-31 16:25:15
【问题描述】:

我将我的模板从 jam 迁移到 pug,然后所有 casperJs 测试都失败了。大多数错误与未找到的 css 选择器有关。这是我的代码示例:

casperJs 测试:

casper.thenOpen("http://localhost:8080/activites/E5555", function() {
    this.wait(5000, function() {
      this.click("a.open-user-dialog");
    });
  });

这里是元素的哈巴狗:

p
    i.fa-icon-plus.fa-icon-success 
    strong: a.open-user-dialog(href="#user-dialog", data-toggle="modal") Add user

这里是测试结果:

FAIL 无法在不存在的选择器上调度 mousedown 事件:a.open-user-dialog

我将不胜感激。

【问题讨论】:

    标签: css bootstrap-4 pug casperjs


    【解决方案1】:

    终于想通了,答案如下: 我在加载页面之前输入了casper.wait(2000, function(){});,它解决了问题。

    casper.wait(2000, function(){});
    casper.thenOpen("http://localhost:8080/activites/E5555", function() {
        this.wait(5000, function() {
          this.click("a.open-user-dialog");
        });
      });
    

    【讨论】:

      猜你喜欢
      • 2018-05-13
      • 1970-01-01
      • 2014-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多