I have Protractor tests that run fine locally (directConnect: true), but when I try to run them on a remote Selenium server (Grid), I always get the following message.
A Jasmine spec timed out. Resetting the WebDriver Control Flow.
Looking at the Failures, the Message and Stack display the following for all my test cases:
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)
I've tried a number of things, such as increasing the jasmine timeout interval, adding earlier timeouts such as getPageTimeout and allScriptsTimeout to the conf, but it still throws the jasmine timeout error. The log shows the following error:
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]])
I know for sure my app is angular and it runs successfully when running locally. I've tried setting
browser.ignoreSynchronization = true
, as well as setting the
rootElement='html#ng-app'
in the conf (bc my ng-app is not in the body, but rather inside the html tag). Framework is set to 'jasmine' although I've tried 'jasmine2' but neither seems to make any difference. On the remote server, I am able to get firefox to start up, and the UI shows me the started firefox session. However it just sits there until the timeout occurs. Any input would be appreciated!
Ways To Toggle The Waiting Feature In Protractor Whenever you want navigation or open a page in the browser that does not use Angular, we can disable this feature of waiting for timeout by passing the argument as false when calling the function i.e. browser. waitForAngularEnabled(false).
Command Timeout This is set to 300 seconds by default.
Protractor can test directly, without the use of Selenium Server, against Chrome and Firefox by setting directConnect: true in config file.
Protractor is a wrapper around Selenium Webdriver that provides an automation test framework, which simulates user interaction with an Angular web application for a range of browsers and mobile devices. It provides all features of Selenium WebDriver along with Angular specific features for seamless end to end testing.
Jasmine needs to know it is running an async process and when that process is supposed to be complete (to proceed with any other test you may be running).
This is obtained by passing done
to the Jasmine async method callback and calling done()
when the async operation is resolved.
If you don't call done()
Jasmine shows a timeout error. I think this should solve your problem.
More info here: Mocking ngResource in Angular unit tests.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With