How to use intervals in protractor / selenium

I am writing a series of automated tests and getting intermittent timeout / synchronization errors. I looked online and said that using intervals would solve this problem.

https://github.com/angular/angular.js/blob/master/src/ng/interval.js

I was wondering how can I include the interval.js file with the rest of the files? I add a line to the protractor-config.js file or bind it elsewhere. If so, how do I tie it?

+1
source share
1 answer

The $interval service is bundled with Angular; You donโ€™t need to upload new files or integrate anything with Protractor. Your tractor driverโ€™s tests are most likely just fine, as are they.

What everyone means when they say that you use $interval is that you (or your developers) need to look at the source code of your application for $timeout or $http requests that happen repeatedly (in a recursive function, a loop or two functions that mistakenly call each other) or, possibly, a $http request that fails (this will be displayed in bright red in the Chrome Developer Console on the Network tab).

The reason the $timeout loop (and the failure of $http requests) is bad is because Protractor, at its discretion, will expect every $timeout callback and $http request to complete completely before it does anything . However, it will not wait for the completion of the $interval callbacks. $interval has almost the same syntax as $timeout , so itโ€™s easy to switch from one to the other - the only difference is that $timeout runs once and $interval runs in a continuous loop. Official docs below:

$ timeout

$ interval

Another answer I posted lists a few more possibilities, as well as a link to the official Protractor list of reasons why this might happen: Waiting periods until the Transcavator synchronizes with the page after 50001 ms

I give you my 90% guarantee that this is one of these problems, but if you provide more information about your situation, I can give some specific advice.

+4
source

Source: https://habr.com/ru/post/1246244/


All Articles