Reputation: 41
I'm using Protractor and I'm trying to automate the process of downloading a file from my app to local system. Chrome has been configured to download files without any prompt dialog. The action of downloading a button is a simple click: element(by.css("#myDownloadLink")).click(); This works as expected. However, Protractor adds an unnecessary delay after this action. The download takes a second and the download request is resolved within 1-2 secs. But, Protractor will hang on this line of code for about a min before moving on to the next line - I guess it's syncing unnecessarily or something.
Does anybody have any ideas on how to resolve or at least work around the issue? Like maybe trigger the Download in a different way (but still through the UI?) and avoid the Protractor syncing/hanging
Thanks
Upvotes: 1
Views: 236
Reputation: 41
I tried that but it did not work. As soon as you turn ignoreSynchronization back on - it continuities the waiting. Here's the solution:
You have to force angular to do things right away: var fixSyncScript = 'var el = document.querySelector("body"); angular.element(el).injector().get("$browser").$$completeOutstandingRequest(angular.noop); return true;'; browser.executeScript(fixSyncScript).then(function (result) { expect(result).toBe(true); });
Upvotes: 0
Reputation: 473873
I'd try to play around with ignoreSynchronization
flag:
browser.ignoreSynchronization = true
// trigger download
browser.ignoreSynchronization = false
Upvotes: 0