【问题标题】:Jasmine spec timeout when running Protractor tests on a remote selenium server在远程硒服务器上运行量角器测试时茉莉花规范超时
【发布时间】:2017-02-04 11:16:46
【问题描述】:

我有在本地运行良好的量角器测试(directConnect:true),但是当我尝试在远程 Selenium 服务器(网格)上运行它们时,我总是收到以下消息。

A Jasmine spec timed out. Resetting the WebDriver Control Flow.

查看失败,消息和堆栈为我的所有测试用例显示以下内容:

Message:
  Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
  Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
    at Timer.listOnTimeout (timers.js:92:15)

我尝试了很多东西,比如增加jasmine超时间隔,在conf中添加getPageTimeout和allScriptsTimeout等较早的超时,但它仍然会抛出jasmine超时错误。日志显示以下错误:

00:03:18.328 INFO - Done: [execute async script: try { return (function (rootSelector, ng12Hybrid, callback) {
var el = document.querySelector(rootSelector);

try {
  if (!ng12Hybrid && window.getAngularTestability) {
    window.getAngularTestability(el).whenStable(callback);
    return;
    }
  if (!window.angular) {
    throw new Error('window.angular is undefined.  This could be either ' +
      'because this is a non-angular page or because your test involves ' +
      'client-side navigation, which can interfere with Protractor\'s ' +
      'bootstrapping.  See http://git.io/v4gXM for details');
}
  if (angular.getTestability) {
  angular.getTestability(el).whenStable(callback);
}   else {
      if (!angular.element(el).injector()) {
    throw new Error('root element (' + rootSelector + ') has no injector.' +
       ' this may mean it is not inside ng-app.');
  }
  angular.element(el).injector().get('$browser').
      notifyWhenNoOutstandingRequests(callback);
}
} catch (err) {
callback(err.message);
}
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body, false]])

我确定我的应用程序是有角度的,并且在本地运行时可以成功运行。我试过设置

browser.ignoreSynchronization = true

,以及设置

rootElement='html#ng-app' 

在 conf 中(我的 ng-app 不在正文中,而是在 html 标记内)。框架设置为 'jasmine' 虽然我尝试过 'jasmine2' 但似乎都没有任何区别。在远程服务器上,我可以启动 firefox,并且 UI 会显示已启动的 firefox 会话。然而,它只是坐在那里,直到发生超时。任何意见将不胜感激!

【问题讨论】:

    标签: angularjs selenium protractor selenium-rc selenium-grid


    【解决方案1】:

    Jasmine 需要知道它正在运行一个异步进程以及该进程应该何时完成(以继续您可能正在运行的任何其他测试)。

    这是通过将done 传递给Jasmine 异步方法回调并在解决异步操作时调用done() 获得的。

    如果不调用done()Jasmine 会显示超时错误。我认为这应该可以解决您的问题。

    更多信息在这里: Mocking ngResource in Angular unit tests.

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2016-09-09
      • 2018-12-09
      • 1970-01-01
      • 1970-01-01
      • 2018-12-21
      • 2018-12-06
      • 2015-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多