There are two things to consider.
The first is that you should properly sequence all protractor actions (as also hinted by @jmcollin92). For this, I typically use .then
on every step.
The second important thing is to make sure that a new test it(...)
only starts after the previous it(...)
has completed.
If you use the latest version of Protractor, you can use Jasmine 2.x and its support for signalling the completion of a test:
it('should do something', function(done) {
clicksomething().then(function() {
expect(...);
done();
});
});
Here the done
argument is invoked to signal that the test is ready. Without this, Protractor will schedule the clicksomething
command, and then immediately move on with the next test, returning to the present test only once clicksomething
has completed.
Since typically both tests inspect and possibly modify the same browser/page, your tests become unpredictable if you let them happen concurrently (one test clicks to the next page, while another is still inspecting the previous page).
If you use an earlier version of Protractor (1.3 as you indicate), the Jasmine 1.3 runs
and waitsFor
functions can be used to simulate this behavior.
Note that the whole point of using Protractor is that Protractor is supposed to know when Angular is finished. So in principle, there should be no need to ever call waitForAngular
(my own test suite with dozens of scenarios does not include a single wait/waitForAngular). The better your application-under-test adheres to Angular's design principles, the fewer WaitForAngular
's you should need.