4

我正在尝试通过让 CasperJS 单击菜单的不同部分来测试导航菜单。前几次点击后,Slimerjs 挂起,大约 5 分钟后,我收到以下错误:addons.repository WARN cacheEnabled: Couldn't get pref: extensions.getAddons.cache.enabled"。

这就是我运行测试的方式:

casperjs 测试测试/ --engine=slimerjs --verbose

这是我的代码:

casper.test.begin('Deal menu is working as expected', 2, function suite(test) {
  casper.start('http://username:password@somesite/section/home', function() {
    test.assertTitle('Main Page', 'Main Page loaded');
    casper.capture('mainPage.png');
  });

  casper.then(function() {
    this.click('#menuId1');
    this.wait(2000, function() {
      test.assertTitle('Menu 1', 'Menu 1 loaded');
      casper.capture('pic1.png');
    });
  });

  casper.then(function() {
    this.click('#menuId2');
    this.wait(2000, function() {
      test.assertTitle('Menu 2', 'Menu 2 loaded');
      casper.capture('pic2.png');
    });
  });

  casper.then(function() {
    this.click('#menuId3');
    this.wait(2000, function() {
      test.assertTitle('Menu 3', 'Menu 3 loaded');
      casper.capture('pic3.png');
    });
  });

  casper.run(function() {
    test.done();
  });
});

一秒钟后casper.then它挂起,过了一会儿它给了我上面提到的错误消息。我还检查了 Firefox(版本 39) extensions.getAddons.cache.enabled 是否等于 true。

当我使用 PhantomJS 运行相同的测试时,它工作正常。有任何想法吗?

4

0 回答 0