The main activities of an e2e test for any web page are to get the DOM elements of that page, interact with them, assign an action to them, and share information with them; then, the user can get the current state of the website. To enable us to perform all these actions, Protractor provides a wide array of APIs (some are from the web driver). In this chapter, we will look at some commonly used APIs.
In the previous chapter, we saw how Protractor works with an Angular project, where we had to interact with UI elements. For that, we used a few Protractor APIs, such as element.all
, by.css
, first
, last
, and getText
. However, we didn't see or understand the workings of these APIs in depth. To understand the workings of APIs in Protractor is very simple, but in real life we will mostly have to work with bigger, complex projects. Hence, it's important that we understand and know more about these APIs in order to interact with the UI and play with its events.