9 Understanding timeouts
This chapter covers
- Understanding and avoiding the causes of timeout errors in Protractor
- Waiting for specific changes in your application, rather than relying on
browser.sleep()
- Understanding flakiness and eliminating it with Protractor
Now that you know how to make basic end-to-end tests for Angular apps, let’s talk about one of the most frequent issues you might run into. Timeout errors are the most common problems people encounter when using Protractor for the first time. Understanding what causes them and how to fix them requires a clear understanding of how browser tests run. You’ll also need to know what Protractor is doing behind the scenes to make tests more reliable by waiting for Angular to be stable while running a test.
In this chapter, we’ll explore how to avoid the common timeout-related pitfalls that new Protractor users stumble into. On the way, you’ll learn how Angular’s change detection works and how Protractor integrates with it. You’ll also learn some advanced techniques for making your own waiting logic. You can find the example code from this chapter at https://www.manning.com/books/testing-angular-applications and http://mng.bz/6k1S.