CasperJs 测试找不到 css 选择器(从 jade 迁移到 pug 后测试失败)

CasperJs test can't found css selector (test broke after migrate from jade to pug)

我将我的模板从 jade 迁移到 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

如有任何帮助,我将不胜感激。

我终于明白了,这里是答案: 我在加载页面之前输入 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");
    });
  });